Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

is_same

Header <boost/core/is_same.hpp>

Authors

  • Peter Dimov
[Warning] Warning

This component is deprecated and will be removed in a future release. Users are recommended to use boost::is_same from Boost.TypeTraits or std::is_same from C++ standard library <type_traits> instead.

The header <boost/core/is_same.hpp> defines the class template boost::core::is_same<T1,T2>. It defines a nested integral constant value which is true when T1 and T2 are the same type, and false when they are not.

In tandem with BOOST_TEST_TRAIT_TRUE and BOOST_TEST_TRAIT_FALSE, is_same is useful for writing tests for traits classes that have to define specific nested types.

namespace boost
{

namespace core
{
    template<class T1, class T2> struct is_same;
}

}
#include <boost/core/lightweight_test_trait.hpp>
#include <boost/core/is_same.hpp>

template<class T> struct X
{
    typedef T& type;
};

using boost::core::is_same;

int main()
{
    BOOST_TEST_TRAIT_TRUE(( is_same<X<int>::type, int&> ));
    return boost::report_errors();
}

PrevUpHomeNext