intrinsics.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*!
  2. @file
  3. Defines macros for commonly used type traits.
  4. @copyright Louis Dionne 2013-2017
  5. Distributed under the Boost Software License, Version 1.0.
  6. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  7. */
  8. #ifndef BOOST_HANA_DETAIL_INTRINSICS_HPP
  9. #define BOOST_HANA_DETAIL_INTRINSICS_HPP
  10. #include <boost/hana/config.hpp>
  11. // We use intrinsics if they are available because it speeds up the
  12. // compile-times.
  13. #if defined(BOOST_HANA_CONFIG_CLANG)
  14. # if __has_extension(is_empty)
  15. # define BOOST_HANA_TT_IS_EMPTY(T) __is_empty(T)
  16. # endif
  17. # if __has_extension(is_final)
  18. # define BOOST_HANA_TT_IS_FINAL(T) __is_final(T)
  19. # endif
  20. // TODO: Right now, this intrinsic is never used directly because of
  21. // https://llvm.org/bugs/show_bug.cgi?id=24173
  22. # if __has_extension(is_constructible) && false
  23. # define BOOST_HANA_TT_IS_CONSTRUCTIBLE(...) __is_constructible(__VA_ARGS__)
  24. # endif
  25. # if __has_extension(is_assignable)
  26. # define BOOST_HANA_TT_IS_ASSIGNABLE(T, U) __is_assignable(T, U)
  27. # endif
  28. # if __has_extension(is_convertible)
  29. # define BOOST_HANA_TT_IS_CONVERTIBLE(T, U) __is_convertible(T, U)
  30. # endif
  31. #endif
  32. #if !defined(BOOST_HANA_TT_IS_EMPTY)
  33. # include <type_traits>
  34. # define BOOST_HANA_TT_IS_EMPTY(T) ::std::is_empty<T>::value
  35. #endif
  36. #if !defined(BOOST_HANA_TT_IS_FINAL)
  37. # include <type_traits>
  38. # define BOOST_HANA_TT_IS_FINAL(T) ::std::is_final<T>::value
  39. #endif
  40. #if !defined(BOOST_HANA_TT_IS_CONSTRUCTIBLE)
  41. # include <type_traits>
  42. # define BOOST_HANA_TT_IS_CONSTRUCTIBLE(...) ::std::is_constructible<__VA_ARGS__>::value
  43. #endif
  44. #if !defined(BOOST_HANA_TT_IS_ASSIGNABLE)
  45. # include <type_traits>
  46. # define BOOST_HANA_TT_IS_ASSIGNABLE(T, U) ::std::is_assignable<T, U>::value
  47. #endif
  48. #if !defined(BOOST_HANA_TT_IS_CONVERTIBLE)
  49. # include <type_traits>
  50. # define BOOST_HANA_TT_IS_CONVERTIBLE(T, U) ::std::is_convertible<T, U>::value
  51. #endif
  52. #endif // !BOOST_HANA_DETAIL_INTRINSICS_HPP