title: Comparing two boost::variant objects using EXPECT_EQ from Google Test
body: <p>I can't compile the last line for the following code:               </p>
  
  <pre><code>typedef boost::variant&lt;std::vector&lt;int8_t&gt;, std::vector&lt;std::string&gt;&gt; Container; 
  
  std::vector&lt;std::string&gt; v1;
  v1.push_back("sd");
  Container c1;
  c1 = v1;
  
  std::vector&lt;int8_t&gt; v2;
  v2.push_back(1);
  v2.push_back(2);
  Container c2;
  c2 = v2;
  
  EXPECT_EQ(c1,c2);
  </code></pre>
  
  <p>However, if I replace it with this line, it works:</p>
  
  <pre><code>EXPECT_EQ(c1==c2,true);
  </code></pre>
  
  <p>EXPECT_EQ is a function from Google Test.</p>
  
  <p>What is the issue here?</p>
  
  <p>The compiler error in VS2010 is as follows:</p>
  
  <pre><code>1&gt;          c:\gtest-1.6.0\include\gtest\gtest-printers.h(338) : see reference to function template instantiation 'void testing_internal::DefaultPrintNonContainerTo&lt;T&gt;(const T &amp;,std::ostream *)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              T=Com::ObjRepWrap::Container
  1&gt;          ]
  1&gt;          c:\gtest-1.6.0\include\gtest\gtest-printers.h(376) : see reference to function template instantiation 'void testing::internal::DefaultPrintTo&lt;T&gt;(testing::internal::IsNotContainer,testing::internal::false_type,const T &amp;,std::ostream *)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              T=Com::ObjRepWrap::Container
  1&gt;          ]
  1&gt;          c:\gtest-1.6.0\include\gtest\gtest-printers.h(600) : see reference to function template instantiation 'void testing::internal::PrintTo&lt;T&gt;(const T &amp;,std::ostream *)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              T=Com::ObjRepWrap::Container
  1&gt;          ]
  1&gt;          c:\gtest-1.6.0\include\gtest\gtest-printers.h(591) : while compiling class template member function 'void testing::internal::UniversalPrinter&lt;T&gt;::Print(const T &amp;,std::ostream *)'
  1&gt;          with
  1&gt;          [
  1&gt;              T=Com::ObjRepWrap::Container
  1&gt;          ]
  1&gt;          c:\gtest-1.6.0\include\gtest\gtest-printers.h(697) : see reference to class template instantiation 'testing::internal::UniversalPrinter&lt;T&gt;' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              T=Com::ObjRepWrap::Container
  1&gt;          ]
  1&gt;          c:\gtest-1.6.0\include\gtest\gtest-printers.h(678) : see reference to function template instantiation 'void testing::internal::UniversalPrint&lt;T&gt;(const T &amp;,std::ostream *)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              T=Com::ObjRepWrap::Container
  1&gt;          ]
  1&gt;          c:\gtest-1.6.0\include\gtest\gtest-printers.h(790) : see reference to function template instantiation 'void testing::internal::UniversalTersePrint&lt;T&gt;(const T &amp;,std::ostream *)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              T=Com::ObjRepWrap::Container
  1&gt;          ]
  1&gt;          c:\gtest-1.6.0\include\gtest\gtest.h(1301) : see reference to function template instantiation 'std::string testing::PrintToString&lt;T1&gt;(const T &amp;)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              T1=Com::ObjRepWrap::Container,
  1&gt;              T=Com::ObjRepWrap::Container
  1&gt;          ]
  1&gt;          c:\gtest-1.6.0\include\gtest\gtest.h(1326) : see reference to function template instantiation 'testing::internal::String testing::internal::FormatForComparisonFailureMessage&lt;T1,T2&gt;(const T1 &amp;,const T2 &amp;)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              T1=Com::ObjRepWrap::Container,
  1&gt;              T2=Com::ObjRepWrap::Container
  1&gt;          ]
  1&gt;          c:\gtest-1.6.0\include\gtest\gtest.h(1353) : see reference to function template instantiation 'testing::AssertionResult testing::internal::CmpHelperEQ&lt;T1,T2&gt;(const char *,const char *,const T1 &amp;,const T2 &amp;)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              T1=Com::ObjRepWrap::Container,
  1&gt;              T2=Com::ObjRepWrap::Container
  1&gt;          ]
  1&gt;          c:\visual studio 2010\projects\db\xxx\main.cpp(127) : see reference to function template instantiation 'testing::AssertionResult testing::internal::EqHelper&lt;lhs_is_null_literal&gt;::Compare&lt;Com::ObjRepWrap::Container,Com::ObjRepWrap::Container&gt;(const char *,const char *,const T1 &amp;,const T2 &amp;)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              lhs_is_null_literal=false,
  1&gt;              T1=Com::ObjRepWrap::Container,
  1&gt;              T2=Com::ObjRepWrap::Container
  1&gt;          ]
  1&gt;c:\boost_1_49_0\boost\variant\detail\variant_io.hpp(64): error C2679: binary '&lt;&lt;' : no operator found which takes a right-hand operand of type 'const T1' (or there is no acceptable conversion)
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(679): could be 'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::operator &lt;&lt;&lt;char,std::char_traits&lt;char&gt;&gt;(std::basic_ostream&lt;_Elem,_Traits&gt; &amp;,const char *)' [found using argument-dependent lookup]
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(726): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::operator &lt;&lt;&lt;char,std::char_traits&lt;char&gt;&gt;(std::basic_ostream&lt;_Elem,_Traits&gt; &amp;,char)' [found using argument-dependent lookup]
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(764): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::operator &lt;&lt;&lt;std::char_traits&lt;char&gt;&gt;(std::basic_ostream&lt;_Elem,_Traits&gt; &amp;,const char *)' [found using argument-dependent lookup]
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(811): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::operator &lt;&lt;&lt;std::char_traits&lt;char&gt;&gt;(std::basic_ostream&lt;_Elem,_Traits&gt; &amp;,char)' [found using argument-dependent lookup]
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(937): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::operator &lt;&lt;&lt;std::char_traits&lt;char&gt;&gt;(std::basic_ostream&lt;_Elem,_Traits&gt; &amp;,const signed char *)' [found using argument-dependent lookup]
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(944): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::operator &lt;&lt;&lt;std::char_traits&lt;char&gt;&gt;(std::basic_ostream&lt;_Elem,_Traits&gt; &amp;,signed char)' [found using argument-dependent lookup]
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(951): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::operator &lt;&lt;&lt;std::char_traits&lt;char&gt;&gt;(std::basic_ostream&lt;_Elem,_Traits&gt; &amp;,const unsigned char *)' [found using argument-dependent lookup]
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(958): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::operator &lt;&lt;&lt;std::char_traits&lt;char&gt;&gt;(std::basic_ostream&lt;_Elem,_Traits&gt; &amp;,unsigned char)' [found using argument-dependent lookup]
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(968): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::operator &lt;&lt;&lt;char,std::char_traits&lt;char&gt;,T&gt;(std::basic_ostream&lt;_Elem,_Traits&gt; &amp;&amp;,_Ty)' [found using argument-dependent lookup]
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;,
  1&gt;              T=T1,
  1&gt;              _Ty=T1
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(1085): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::operator &lt;&lt;&lt;char,std::char_traits&lt;char&gt;&gt;(std::basic_ostream&lt;_Elem,_Traits&gt; &amp;,const std::error_code &amp;)' [found using argument-dependent lookup]
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\boost_1_49_0\boost\blank.hpp(93): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;boost::operator &lt;&lt;&lt;char,std::char_traits&lt;char&gt;&gt;(std::basic_ostream&lt;_Elem,_Traits&gt; &amp;,const boost::blank &amp;)'
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(186): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::basic_ostream&lt;_Elem,_Traits&gt;::operator &lt;&lt;(std::basic_ostream&lt;_Elem,_Traits&gt; &amp;(__cdecl *)(std::basic_ostream&lt;_Elem,_Traits&gt; &amp;))'
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(192): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::basic_ostream&lt;_Elem,_Traits&gt;::operator &lt;&lt;(std::basic_ios&lt;_Elem,_Traits&gt; &amp;(__cdecl *)(std::basic_ios&lt;_Elem,_Traits&gt; &amp;))'
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(199): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::basic_ostream&lt;_Elem,_Traits&gt;::operator &lt;&lt;(std::ios_base &amp;(__cdecl *)(std::ios_base &amp;))'
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(206): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::basic_ostream&lt;_Elem,_Traits&gt;::operator &lt;&lt;(std::_Bool)'
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(226): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::basic_ostream&lt;_Elem,_Traits&gt;::operator &lt;&lt;(short)'
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(260): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::basic_ostream&lt;_Elem,_Traits&gt;::operator &lt;&lt;(unsigned short)'
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(280): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::basic_ostream&lt;_Elem,_Traits&gt;::operator &lt;&lt;(int)'
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(305): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::basic_ostream&lt;_Elem,_Traits&gt;::operator &lt;&lt;(unsigned int)'
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(325): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::basic_ostream&lt;_Elem,_Traits&gt;::operator &lt;&lt;(long)'
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(345): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::basic_ostream&lt;_Elem,_Traits&gt;::operator &lt;&lt;(unsigned long)'
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(366): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::basic_ostream&lt;_Elem,_Traits&gt;::operator &lt;&lt;(__int64)'
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(386): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::basic_ostream&lt;_Elem,_Traits&gt;::operator &lt;&lt;(unsigned __int64)'
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(407): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::basic_ostream&lt;_Elem,_Traits&gt;::operator &lt;&lt;(float)'
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(427): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::basic_ostream&lt;_Elem,_Traits&gt;::operator &lt;&lt;(double)'
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(447): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::basic_ostream&lt;_Elem,_Traits&gt;::operator &lt;&lt;(long double)'
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(467): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::basic_ostream&lt;_Elem,_Traits&gt;::operator &lt;&lt;(const void *)'
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\ostream(487): or       'std::basic_ostream&lt;_Elem,_Traits&gt; &amp;std::basic_ostream&lt;_Elem,_Traits&gt;::operator &lt;&lt;(std::basic_streambuf&lt;_Elem,_Traits&gt; *)'
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          while trying to match the argument list '(std::basic_ostream&lt;_Elem,_Traits&gt;, const T1)'
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\boost_1_49_0\boost\variant\variant.hpp(858) : see reference to function template instantiation 'void boost::detail::variant::printer&lt;OStream&gt;::operator ()&lt;const T&gt;(const T &amp;) const' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              OStream=std::basic_ostream&lt;char,std::char_traits&lt;char&gt;&gt;,
  1&gt;              T=T1
  1&gt;          ]
  1&gt;          c:\boost_1_49_0\boost\variant\detail\visitation_impl.hpp(145) : see reference to function template instantiation 'void boost::detail::variant::invoke_visitor&lt;Visitor&gt;::internal_visit&lt;const T&gt;(T &amp;,int)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              Visitor=boost::detail::variant::printer&lt;std::basic_ostream&lt;char,std::char_traits&lt;char&gt;&gt;&gt;,
  1&gt;              T=T1
  1&gt;          ]
  1&gt;          c:\boost_1_49_0\boost\variant\detail\visitation_impl.hpp(173) : see reference to function template instantiation 'void boost::detail::variant::visitation_impl_invoke_impl&lt;Visitor,VoidPtrCV,T&gt;(int,Visitor &amp;,VoidPtrCV,T *,boost::mpl::false_)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              Visitor=boost::detail::variant::invoke_visitor&lt;boost::detail::variant::printer&lt;std::basic_ostream&lt;char,std::char_traits&lt;char&gt;&gt;&gt;&gt;,
  1&gt;              VoidPtrCV=const void *,
  1&gt;              T=T1
  1&gt;          ]
  1&gt;          c:\boost_1_49_0\boost\variant\detail\visitation_impl.hpp(256) : see reference to function template instantiation 'void boost::detail::variant::visitation_impl_invoke&lt;Visitor,VoidPtrCV,T1,NoBackupFlag&gt;(int,Visitor &amp;,VoidPtrCV,T *,NoBackupFlag,int)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              Visitor=boost::detail::variant::invoke_visitor&lt;boost::detail::variant::printer&lt;std::basic_ostream&lt;char,std::char_traits&lt;char&gt;&gt;&gt;&gt;,
  1&gt;              VoidPtrCV=const void *,
  1&gt;              NoBackupFlag=boost::variant&lt;std::vector&lt;testing::internal::string&gt;,std::vector&lt;int8_t&gt;&gt;::has_fallback_type_,
  1&gt;              T=T1
  1&gt;          ]
  </code></pre>