is_same.qbk 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. [/
  2. Copyright 2014 Peter Dimov
  3. Distributed under the Boost Software License, Version 1.0.
  4. See accompanying file LICENSE_1_0.txt
  5. or copy at http://boost.org/LICENSE_1_0.txt
  6. ]
  7. [section:is_same is_same]
  8. [simplesect Authors]
  9. * Peter Dimov
  10. [endsimplesect]
  11. [section Header <boost/core/is_same.hpp>]
  12. The header `<boost/core/is_same.hpp>` defines the class template
  13. `boost::core::is_same<T1,T2>`. It defines a nested integral constant
  14. `value` which is `true` when `T1` and `T2` are the same type, and
  15. `false` when they are not.
  16. In tandem with `BOOST_TEST_TRAIT_TRUE` and `BOOST_TEST_TRAIT_FALSE`,
  17. `is_same` is useful for writing tests for traits classes that have
  18. to define specific nested types.
  19. [section Synopsis]
  20. ``
  21. namespace boost
  22. {
  23. namespace core
  24. {
  25. template<class T1, class T2> struct is_same;
  26. }
  27. }
  28. ``
  29. [endsect]
  30. [section Example]
  31. ``
  32. #include <boost/core/lightweight_test_trait.hpp>
  33. #include <boost/core/is_same.hpp>
  34. template<class T> struct X
  35. {
  36. typedef T& type;
  37. };
  38. using boost::core::is_same;
  39. int main()
  40. {
  41. BOOST_TEST_TRAIT_TRUE(( is_same<X<int>::type, int&> ));
  42. return boost::report_errors();
  43. }
  44. ``
  45. [endsect]
  46. [endsect]
  47. [endsect]