has_constant_size.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef BOOST_HASH2_HAS_CONSTANT_SIZE_HPP_INCLUDED
  2. #define BOOST_HASH2_HAS_CONSTANT_SIZE_HPP_INCLUDED
  3. // Copyright 2024 Peter Dimov
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // https://www.boost.org/LICENSE_1_0.txt
  6. #include <type_traits>
  7. #include <utility>
  8. namespace boost
  9. {
  10. // forward declaration
  11. template<class T, std::size_t N> class array;
  12. namespace hash2
  13. {
  14. // forward declaration
  15. template<std::size_t N> class digest;
  16. // detail::has_tuple_size
  17. namespace detail
  18. {
  19. template<class T, class En = void> struct has_tuple_size: std::false_type
  20. {
  21. };
  22. template<class T> struct has_tuple_size<T,
  23. typename std::enable_if<
  24. std::tuple_size<T>::value == std::tuple_size<T>::value
  25. >::type
  26. >: std::true_type
  27. {
  28. };
  29. } // namespace detail
  30. // has_constant_size
  31. template<class T> struct has_constant_size: detail::has_tuple_size<T>
  32. {
  33. };
  34. template<class T, std::size_t N> struct has_constant_size< boost::array<T, N> >: std::true_type
  35. {
  36. };
  37. template<std::size_t N> struct has_constant_size< digest<N> >: std::true_type
  38. {
  39. };
  40. template<class T> struct has_constant_size<T const>: has_constant_size<T>
  41. {
  42. };
  43. } // namespace hash2
  44. } // namespace boost
  45. #endif // #ifndef BOOST_HASH2_HAS_CONSTANT_SIZE_HPP_INCLUDED