尝试使用clang在C ++中引用带有const的重载方法

时间:2016-01-27 20:14:14

标签: c++ clang overloading clang++

在clang中有this file。我正在尝试引用其中一个重载方法:

00909   std::string getAsString(const PrintingPolicy &Policy) const;

我试过了:

std::__cxx11::basic_string<char> (&p2)(const clang::PrintingPolicy&) = &clang::QualType::getAsString;

并得到:

REPL:1:73: error: address of overloaded function 'getAsString' does not match required type 'std::__cxx11::basic_string<char> (const clang::PrintingPolicy &)'
std::__cxx11::basic_string<char> (&p2)(const clang::PrintingPolicy&) = &clang::QualType::getAsString
/home/a/julia/usr/bin/../include/clang/AST/Type.h:905:15: note: candidate function has different qualifiers **(expected none but found const)**
  std::string getAsString(const PrintingPolicy &Policy) const;

我也尝试过:

std::__cxx11::basic_string<char> (&p1)(clang::PrintingPolicy&) = &clang::QualType::getAsString;

并得到:

candidate function has type mismatch at 1st parameter **(expected 'clang::PrintingPolicy &' but has 'const clang::PrintingPolicy &')**

我做错了什么还是编译器坏了?

0 个答案:

没有答案