2
누구나 함께이 라이브러리를 사용합니까? cxx-prettyprint 및 glm. 알아낼 수없는 컴파일 시간 문제가 발생했습니다. 당신이 "SUITE"와 "TEST"로 혼동하는 경우이 코드는 UnitTest++
를 사용하고 있기 때문에glm 및 cxx-prettyprint, clang : 템플릿 정의에 표시되지 않는 'operator <<'함수 호출
9 #include "Math.h"
10 #include "UnitTestConfigurator.h"
11 #include <vector>
12 using namespace std;
13
14 ostream& operator <<(ostream& os, const v3& v) {
15 string s("a v3");
16 os << s;
17 return os;
18 }
19
20 SUITE(MathTests) {
21 TEST(PrintVectorType) {
22 v3 vec3;
23 cout << vec3;
24 }
25 TEST(PrintVectorofVectors) {
26 vector<v3> v;
27 cout << v;
28 }
29 }
, 그것은이다.
Math.h는 거기에 있습니다
# include "../glm/glm/glm.hpp"
typedef glm::vec2 v2;
typedef glm::vec3 v3;
다음은 오류입니다 :
In file included from Math.cpp:10:
In file included from ./UnitTestConfigurator.h:26:
In file included from ./util.h:62:
./prettyprint.hpp:212:32: error: call to function 'operator<<' that is neither visible in the
template definition nor found by argument-dependent lookup
stream << *it;
^
./prettyprint.hpp:295:9: note: in instantiation of member function
'pretty_print::print_container_helper<std::__1::vector<glm::detail::tvec3<float, 0>,
std::__1::allocator<glm::detail::tvec3<float, 0> > >, char,
std::__1::char_traits<char>,
pretty_print::delimiters<std::__1::vector<glm::detail::tvec3<float, 0>,
std::__1::allocator<glm::detail::tvec3<float, 0> > >, char> >::operator()' requested
here
helper(stream);
^
./prettyprint.hpp:305:23: note: in instantiation of function template specialization
'std::operator<<<std::__1::vector<glm::detail::tvec3<float, 0>,
std::__1::allocator<glm::detail::tvec3<float, 0> > >, char,
std::__1::char_traits<char>,
pretty_print::delimiters<std::__1::vector<glm::detail::tvec3<float, 0>,
std::__1::allocator<glm::detail::tvec3<float, 0> > >, char> >' requested here
return stream << ::pretty_print::print_container_helper<T, TChar, TCharTraits...
^
Math.cpp:27:8: note: in instantiation of function template specialization
'std::operator<<<std::__1::vector<glm::detail::tvec3<float, 0>,
std::__1::allocator<glm::detail::tvec3<float, 0> > >, char, std::__1::char_traits<char>
>' requested here
cout << v;
^
Math.cpp:14:10: note: 'operator<<' should be declared prior to the call site or in namespace
'glm::detail'
ostream& operator <<(ostream& os, const v3& v) {
^
아, 마지막으로 그 소리 오류 노트는 내'연산자의 정의는 <<'다른 네임 스페이스에 가야 방법에 대한 매우 명확한 것으로 보인다 –