NDK模板实例化无法编译运算符<<

时间:2018-12-13 06:45:16

标签: android-ndk

我在自定义类上使用运算符<<。在VS2017中可以正常编译,而在NDK中则可以。

static std::ostream & operator << (std::ostream & os, const V & v2) { return os << V.x; }

在NDK中,它会遍历basic_ostream中的模板专业化列表,但找不到它。

 D:/Library/android-ndk-r16/build//../sources/cxx-stl/llvm-libc++/include\ostream:1036:10: error: invalid operands to binary expression ('std::__ndk1::basic_ostringstream<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >' and 'const cocos2d::Vec2')
  __os << __x;

 D:/Library/android-ndk-r16/build//../sources/cxx-stl/llvm-libc++/include\ostream:218:20: note: candidate function not viable: no known conversion from 'const V' to 'const void *' for 1st argument; take the address of the argument with &
  basic_ostream& operator<<(const void* __p);
                 ^
 D:/Library/android-ndk-r16/build//../sources/cxx-stl/llvm-libc++/include\ostream:755:1: note: candidate function not viable: no known conversion from 'const V' to 'char' for 2nd argument operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)

  D:/Library/android-ndk-r16/build//../sources/cxx-stl/llvm-libc++/include\ostream:788:1: note: candidate function not viable: no known conversion from 'const V' to 'char' for 2nd argument operator<<(basic_ostream<char, _Traits>& __os, char __c)

。等等

0 个答案:

没有答案