is_acceptable.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* Copyright 2016-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_ACCEPTABLE_HPP
  9. #define BOOST_POLY_COLLECTION_DETAIL_IS_ACCEPTABLE_HPP
  10. #if defined(_MSC_VER)
  11. #pragma once
  12. #endif
  13. #include <boost/mp11/algorithm.hpp>
  14. #include <boost/poly_collection/detail/is_closed_collection.hpp>
  15. #include <boost/poly_collection/detail/is_moveable.hpp>
  16. #include <type_traits>
  17. namespace boost{
  18. namespace poly_collection{
  19. namespace detail{
  20. /* is_acceptable can be further specialized by (open collection) Model when
  21. * the std type_traits classes fail to give the right info (as it can happen
  22. * with class templates whose nominally existing operators do not compile for
  23. * certain instantiations).
  24. */
  25. template<typename T,typename Model,typename=void>
  26. struct is_acceptable:std::integral_constant<
  27. bool,
  28. Model::template is_implementation<T>::value&&is_moveable<T>::value
  29. >{};
  30. /* Closed collections are defined by having a compile-time fixed list of
  31. * acceptable types.
  32. */
  33. template<typename T,typename Model>
  34. struct is_acceptable<
  35. T,Model,
  36. typename std::enable_if<is_closed_collection<Model>::value>::type
  37. >:mp11::mp_contains<typename Model::acceptable_type_list,T>{};
  38. } /* namespace poly_collection::detail */
  39. } /* namespace poly_collection */
  40. } /* namespace boost */
  41. #endif