interoperable.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 <type_traits>
  10. #include <boost/iterator/detail/type_traits/disjunction.hpp>
  11. namespace boost {
  12. namespace iterators {
  13. //
  14. // Meta function that determines whether two
  15. // iterator types are considered interoperable.
  16. //
  17. // Two iterator types A,B are considered interoperable if either
  18. // A is convertible to B or vice versa.
  19. // This interoperability definition is in sync with the
  20. // standards requirements on constant/mutable container
  21. // iterators (23.1 [lib.container.requirements]).
  22. //
  23. // For compilers that don't support is_convertible
  24. // is_interoperable gives false positives. See comments
  25. // on operator implementation for consequences.
  26. //
  27. template< typename A, typename B >
  28. struct is_interoperable :
  29. public detail::disjunction< std::is_convertible< A, B >, std::is_convertible< B, A > >
  30. {
  31. };
  32. } // namespace iterators
  33. using iterators::is_interoperable;
  34. } // namespace boost
  35. #endif // BOOST_INTEROPERABLE_23022003THW_HPP