is_fundamental.hpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //---------------------------------------------------------------------------//
  2. // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
  3. //
  4. // Distributed under the Boost Software License, Version 1.0
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. //
  8. // See http://boostorg.github.com/compute for more information.
  9. //---------------------------------------------------------------------------//
  10. #ifndef BOOST_COMPUTE_TYPE_TRAITS_IS_FUNDAMENTAL_HPP
  11. #define BOOST_COMPUTE_TYPE_TRAITS_IS_FUNDAMENTAL_HPP
  12. #include <boost/compute/types/fundamental.hpp>
  13. namespace boost {
  14. namespace compute {
  15. /// Meta-function returning \c true if \p T is a fundamental (i.e.
  16. /// built-in) type.
  17. ///
  18. /// For example,
  19. /// \code
  20. /// is_fundamental<float>::value == true
  21. /// is_fundamental<std::pair<int, float>>::value == false
  22. /// \endcode
  23. template<class T>
  24. struct is_fundamental : public boost::false_type {};
  25. /// \internal_
  26. #define BOOST_COMPUTE_DETAIL_DECLARE_FUNDAMENTAL(type) \
  27. template<> struct is_fundamental<BOOST_PP_CAT(type, _)> : boost::true_type {}; \
  28. template<> struct is_fundamental<BOOST_PP_CAT(BOOST_PP_CAT(type, 2), _)> : boost::true_type {}; \
  29. template<> struct is_fundamental<BOOST_PP_CAT(BOOST_PP_CAT(type, 4), _)> : boost::true_type {}; \
  30. template<> struct is_fundamental<BOOST_PP_CAT(BOOST_PP_CAT(type, 8), _)> : boost::true_type {}; \
  31. template<> struct is_fundamental<BOOST_PP_CAT(BOOST_PP_CAT(type, 16), _)> : boost::true_type {}; \
  32. template<> struct is_fundamental<BOOST_PP_CAT(cl_, BOOST_PP_CAT(type, 2))> : boost::true_type {}; \
  33. template<> struct is_fundamental<BOOST_PP_CAT(cl_, BOOST_PP_CAT(type, 4))> : boost::true_type {}; \
  34. template<> struct is_fundamental<BOOST_PP_CAT(cl_, BOOST_PP_CAT(type, 8))> : boost::true_type {}; \
  35. template<> struct is_fundamental<BOOST_PP_CAT(cl_, BOOST_PP_CAT(type, 16))> : boost::true_type {};
  36. BOOST_COMPUTE_DETAIL_DECLARE_FUNDAMENTAL(char)
  37. BOOST_COMPUTE_DETAIL_DECLARE_FUNDAMENTAL(uchar)
  38. BOOST_COMPUTE_DETAIL_DECLARE_FUNDAMENTAL(short)
  39. BOOST_COMPUTE_DETAIL_DECLARE_FUNDAMENTAL(ushort)
  40. BOOST_COMPUTE_DETAIL_DECLARE_FUNDAMENTAL(int)
  41. BOOST_COMPUTE_DETAIL_DECLARE_FUNDAMENTAL(uint)
  42. BOOST_COMPUTE_DETAIL_DECLARE_FUNDAMENTAL(long)
  43. BOOST_COMPUTE_DETAIL_DECLARE_FUNDAMENTAL(ulong)
  44. BOOST_COMPUTE_DETAIL_DECLARE_FUNDAMENTAL(float)
  45. BOOST_COMPUTE_DETAIL_DECLARE_FUNDAMENTAL(double)
  46. #undef BOOST_COMPUTE_DETAIL_DECLARE_FUNDAMENTAL
  47. } // end compute namespace
  48. } // end boost namespace
  49. #endif // BOOST_COMPUTE_TYPE_TRAITS_IS_FUNDAMENTAL_HPP