is_container.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*-----------------------------------------------------------------------------+
  2. Copyright (c) 2010-2010: Joachim Faulhaber
  3. +------------------------------------------------------------------------------+
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENCE.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. +-----------------------------------------------------------------------------*/
  8. #ifndef BOOST_ICL_TYPE_TRAITS_IS_CONTAINER_HPP_JOFA_100828
  9. #define BOOST_ICL_TYPE_TRAITS_IS_CONTAINER_HPP_JOFA_100828
  10. #include <boost/mpl/has_xxx.hpp>
  11. #include <boost/mpl/bool.hpp>
  12. #include <boost/mpl/and.hpp>
  13. #include <boost/mpl/not.hpp>
  14. #include <boost/type_traits/is_same.hpp>
  15. #include <boost/icl/type_traits/element_type_of.hpp>
  16. #include <boost/icl/type_traits/segment_type_of.hpp>
  17. #include <boost/icl/type_traits/size_type_of.hpp>
  18. #include <boost/icl/type_traits/is_map.hpp>
  19. namespace boost{ namespace icl
  20. {
  21. namespace detail
  22. {
  23. BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator)
  24. BOOST_MPL_HAS_XXX_TRAIT_DEF(reference)
  25. }
  26. template <class Type>
  27. struct is_container
  28. : mpl::bool_<
  29. detail::has_value_type<Type>::value &&
  30. detail::has_iterator<Type>::value &&
  31. detail::has_size_type<Type>::value &&
  32. detail::has_reference<Type>::value>
  33. {};
  34. template <class Type>
  35. struct is_std_set
  36. {
  37. typedef is_std_set type;
  38. BOOST_STATIC_CONSTANT(bool,
  39. value = (mpl::and_< is_container<Type>
  40. , detail::has_key_type<Type>
  41. , boost::is_same< typename key_type_of<Type>::type
  42. , typename value_type_of<Type>::type >
  43. , mpl::not_<detail::has_segment_type<Type> >
  44. >::value )
  45. );
  46. };
  47. }} // namespace boost icl
  48. #endif