symmetrical_base.hpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // Boost.Bimap
  2. //
  3. // Copyright (c) 2006-2007 Matias Capeletto
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. /// \file relation/symmetrical_base.hpp
  9. /// \brief Base class for symmetrical types
  10. #ifndef BOOST_BIMAP_RELATION_SYMMETRICAL_BASE_HPP
  11. #define BOOST_BIMAP_RELATION_SYMMETRICAL_BASE_HPP
  12. #if defined(_MSC_VER)
  13. #pragma once
  14. #endif
  15. #include <boost/config.hpp>
  16. #include <boost/mpl/if.hpp>
  17. #include <boost/type_traits/remove_const.hpp>
  18. // Boost.Bimap
  19. #include <boost/bimap/tags/tagged.hpp>
  20. #include <boost/bimap/tags/support/default_tagged.hpp>
  21. #include <boost/bimap/relation/member_at.hpp>
  22. namespace boost {
  23. namespace bimaps {
  24. namespace relation {
  25. /// \brief Base of symmetrical tagged types.
  26. /**
  27. **/
  28. template< class TA, class TB, bool force_mutable = false >
  29. class symmetrical_base
  30. {
  31. public:
  32. typedef BOOST_DEDUCED_TYPENAME tags::support::default_tagged
  33. <
  34. TA,
  35. member_at::left
  36. >::type tagged_left_type;
  37. typedef BOOST_DEDUCED_TYPENAME tags::support::default_tagged
  38. <
  39. TB,
  40. member_at::right
  41. >::type tagged_right_type;
  42. public:
  43. //@{
  44. /// The type stored in the relation
  45. typedef BOOST_DEDUCED_TYPENAME ::boost::mpl::if_c< force_mutable,
  46. BOOST_DEDUCED_TYPENAME ::boost::remove_const<
  47. BOOST_DEDUCED_TYPENAME tagged_left_type::value_type >::type,
  48. BOOST_DEDUCED_TYPENAME tagged_left_type::value_type
  49. >::type left_value_type;
  50. typedef BOOST_DEDUCED_TYPENAME ::boost::mpl::if_c< force_mutable,
  51. BOOST_DEDUCED_TYPENAME ::boost::remove_const<
  52. BOOST_DEDUCED_TYPENAME tagged_right_type::value_type >::type,
  53. BOOST_DEDUCED_TYPENAME tagged_right_type::value_type
  54. >::type right_value_type;
  55. //@}
  56. //@{
  57. /// The tag of the member. By default it is \c member_at::{side}
  58. typedef BOOST_DEDUCED_TYPENAME tagged_left_type ::tag left_tag;
  59. typedef BOOST_DEDUCED_TYPENAME tagged_right_type::tag right_tag;
  60. //@}
  61. };
  62. } // namespace relation
  63. } // namespace bimaps
  64. } // namespace boost
  65. #endif // BOOST_BIMAP_RELATION_SYMMETRICAL_BASE_HPP