<div dir="ltr">Hello all,<div><br></div><div>I have the following lines of code. To run it, I need to change the rule of the function "EnterTokenStream" from private to a public function in "/usr/local/include/clang/Lex/Preprocessor.h". In this case this code will working with raw pointer "*Toks".</div><div><div>------------------------------------</div><div>PP.Lex(Tok);<br></div><div><div>SmallVector<Token, 4> Pragma;<br></div><div>Pragma.push_back(Tok);</div><div><br></div><div>Token *Toks = new Token[Pragma.size()];</div><div>std::copy(Pragma.begin(), Pragma.end(), Toks);</div><div>PP.EnterTokenStream(Toks, Pragma.size(), true, true);</div></div><div>--------------------------------------------------------------</div><div><br></div><div>But default rule for the function "EnterTokenStream" is private. So I cannot call this function, and I should call this one:</div><div>---------------------------------------------</div><div>void EnterTokenStream(std::unique_ptr<Token[]> Toks, unsigned NumToks, bool DisableMacroExpansion)</div><div>---------------------------------------------</div><div><br></div><div><br></div><div>First argument of this function needs  "std::unique_ptr<Token[]> Toks". So I have tried to define Toks as a unique pointer. I did like this:</div><div>--------------------------------------------</div><div><div>PP.Lex(Tok);<br></div><div><div>SmallVector<Token, 4> Pragma;<br></div><div>Pragma.push_back(Tok);</div><div><br></div><div>unique_ptr<Token[]> Toks(new Token[Pragma.size()]);</div><div>std::copy(Pragma.begin(), Pragma.end(), Toks);</div><div>PP.EnterTokenStream(Toks, Pragma.size(), true);</div></div></div><div>------------------------------------------------</div><div><br></div><div>but it gives me the following error for std::copy:</div><div>---------------------------------------------</div><div><div> error: use of deleted function ‘std::unique_ptr<_Tp [], _Dp>::unique_ptr(const std::unique_ptr<_Tp [], _Dp>&) [with _Tp = clang::Token; _Dp = std::default_delete<clang::Token []>]’</div><div>    std::copy(Pragma.begin(), Pragma.end(), Toks);</div></div><div>----------------------------------------------------------</div><div><br></div><div>and the same error for EnterTokenStream:</div><div>------------------------------------------------------</div><div><div>error: use of deleted function ‘std::unique_ptr<_Tp [], _Dp>::unique_ptr(const std::unique_ptr<_Tp [], _Dp>&) [with _Tp = clang::Token; _Dp = std::default_delete<clang::Token []>]’</div><div>    PP.EnterTokenStream(Toks, Pragma.size(), true);</div></div><div>------------------------------------------------------------</div><div><br></div><div>Can anyone help me how to fix this errors? How can I change my original code to something that I can use the new EnterTokenStream function?</div><div><br></div><div>Thank you.</div><div><br>-- </div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div>------<br>----------<br>Masoud Ataei (Mr.)<br><div><div><br></div></div></div></div></div></div></div></div></div></div></div></div>
</div></div>