is_closed_collection.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* Copyright 2024 Joaquin M Lopez Munoz.
  2. * Distributed under the Boost Software License, Version 1.0.
  3. * (See accompanying file LICENSE_1_0.txt or copy at
  4. * http://www.boost.org/LICENSE_1_0.txt)
  5. *
  6. * See http://www.boost.org/libs/poly_collection for library home page.
  7. */
  8. #ifndef BOOST_POLY_COLLECTION_DETAIL_IS_CLOSED_COLLECTION_HPP
  9. #define BOOST_POLY_COLLECTION_DETAIL_IS_CLOSED_COLLECTION_HPP
  10. #if defined(_MSC_VER)
  11. #pragma once
  12. #endif
  13. #include <boost/mp11/algorithm.hpp>
  14. #include <boost/mp11/set.hpp>
  15. #include <boost/poly_collection/detail/is_moveable.hpp>
  16. #include <boost/type_traits/make_void.hpp>
  17. #include <type_traits>
  18. namespace boost{
  19. namespace poly_collection{
  20. namespace detail{
  21. template<typename Model,typename=void>
  22. struct is_closed_collection:std::false_type{};
  23. template<typename Model>
  24. struct is_closed_collection<
  25. Model,void_t<typename Model::acceptable_type_list>
  26. >:std::true_type
  27. {
  28. using type_list=typename Model::acceptable_type_list;
  29. static_assert(
  30. mp11::mp_is_set<type_list>::value,
  31. "all types in a closed collection must be distinct");
  32. static_assert(
  33. mp11::mp_all_of<type_list,is_moveable>::value,
  34. "all types of a closed collection must be nothrow move constructible "
  35. "or else move constructible and move assignable");
  36. };
  37. } /* namespace poly_collection::detail */
  38. } /* namespace poly_collection */
  39. } /* namespace boost */
  40. #endif