interoperable.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // (C) Copyright David Abrahams 2002.
  2. // (C) Copyright Jeremy Siek 2002.
  3. // (C) Copyright Thomas Witt 2002.
  4. // Distributed under the Boost Software License, Version 1.0. (See
  5. // accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #ifndef BOOST_INTEROPERABLE_23022003THW_HPP
  8. # define BOOST_INTEROPERABLE_23022003THW_HPP
  9. # include <boost/mpl/bool.hpp>
  10. # include <boost/mpl/or.hpp>
  11. # include <boost/type_traits/is_convertible.hpp>
  12. # include <boost/iterator/detail/config_def.hpp> // must appear last
  13. namespace boost {
  14. namespace iterators {
  15. //
  16. // Meta function that determines whether two
  17. // iterator types are considered interoperable.
  18. //
  19. // Two iterator types A,B are considered interoperable if either
  20. // A is convertible to B or vice versa.
  21. // This interoperability definition is in sync with the
  22. // standards requirements on constant/mutable container
  23. // iterators (23.1 [lib.container.requirements]).
  24. //
  25. // For compilers that don't support is_convertible
  26. // is_interoperable gives false positives. See comments
  27. // on operator implementation for consequences.
  28. //
  29. template <typename A, typename B>
  30. struct is_interoperable
  31. # ifdef BOOST_NO_STRICT_ITERATOR_INTEROPERABILITY
  32. : mpl::true_
  33. # else
  34. : mpl::or_<
  35. is_convertible< A, B >
  36. , is_convertible< B, A > >
  37. # endif
  38. {
  39. };
  40. } // namespace iterators
  41. using iterators::is_interoperable;
  42. } // namespace boost
  43. # include <boost/iterator/detail/config_undef.hpp>
  44. #endif // BOOST_INTEROPERABLE_23022003THW_HPP