Ubuntu: Error: ‘is_same’ is not a member of ‘std’ when build c++ project in ubuntu?



Question:

I have a small project and i get an error ‘is_same’ is not a member of ‘std’ when building. this is some code:

template <class T>  T* UcmExportFactory::Unwrap (T* ptr)  {      Utils::IUcmWrapper* wrapper = dynamic_cast<Utils::IUcmWrapper*> (ptr);        // If the requested Ucm inteface is derived from an another (such as IUcmV from IUcmUnionValue), specify that whether we want the base class pointer or not.      bool interfaceForAbstractBase = (std::is_same<IUcmUnionValue, T>::value || std::is_same<IUcmDiagCodedType, T>::value);      return (wrapper) ? boost::any_cast<T*> ( wrapper->GetWrappedObject (interfaceForAbstractBase) ) : ptr;  }  

Anyone can help me. I included header #include <type_traits>. Thanks.


Solution:1

std::is_same is a C++11 feature. Ubuntu 12.04 has GCC 4.6.3, which has only incomplete C++0x (not yet C++11) support. You can try by specifying the standard:

g++ --std=c++0x ...  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »