Add Boost.Test karmic valgrind suppressions
[senf.git] / boost_ext / boost / bimap / relation / support / data_extractor.hpp
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
9 /// \file relation/support/data_extractor.hpp
10 /// \brief Data extraction functor.
11
12 #ifndef BOOST_BIMAP_RELATION_SUPPORT_DATA_EXTRACTOR_HPP
13 #define BOOST_BIMAP_RELATION_SUPPORT_DATA_EXTRACTOR_HPP
14
15 #if defined(_MSC_VER) && (_MSC_VER>=1200)
16 #pragma once
17 #endif
18
19 #include <boost/config.hpp>
20
21 #include <boost/bimap/relation/detail/metadata_access_builder.hpp>
22
23 /** \struct boost::bimaps::relation::support::data_extractor
24
25 \brief Data extraction functor.
26
27 \ingroup relation_group
28                                                                     **/
29
30 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
31
32 namespace boost {
33 namespace bimaps {
34 namespace relation {
35 namespace support {
36
37 template< class Tag, class Relation >
38 struct data_extractor_implementation;
39
40 template< class Relation >
41 struct data_extractor_implementation< member_at::left, Relation > :
42     public std::unary_function<Relation,BOOST_DEDUCED_TYPENAME Relation::left_value_type>
43 {
44     BOOST_DEDUCED_TYPENAME Relation::left_value_type const &
45         operator()(Relation const & rel) const
46     {
47         return rel.left;
48     }
49
50     BOOST_DEDUCED_TYPENAME Relation::left_value_type &
51         operator()(Relation       & rel) const
52     {
53         return rel.left;
54     }
55 };
56
57 template< class Relation >
58 struct data_extractor_implementation< member_at::right, Relation > :
59     public std::unary_function<Relation,BOOST_DEDUCED_TYPENAME Relation::right_value_type>
60 {
61     BOOST_DEDUCED_TYPENAME Relation::right_value_type const & 
62         operator()(Relation const & rel) const
63     {
64         return rel.right;
65     }
66
67     BOOST_DEDUCED_TYPENAME Relation::right_value_type & 
68         operator()(Relation       & rel) const
69     {
70         return rel.right;
71     }
72 };
73
74 template< class Tag, class Relation >
75 struct data_extractor
76 {
77     typedef data_extractor_implementation
78     <
79         BOOST_DEDUCED_TYPENAME member_with_tag<Tag,Relation>::type,
80         Relation
81
82     > type;
83 };
84
85 template< class Relation >
86 struct both_keys_extractor
87 {
88     typedef BOOST_DEDUCED_TYPENAME Relation::storage_base result_type;
89
90      const result_type & operator()(const Relation & rel) const
91     {
92         return rel;
93     }
94
95     result_type & operator()( Relation & rel) const
96     {
97         return rel;
98     }
99 };
100
101 } // namespace support
102 } // namespace relation
103 } // namespace bimaps
104 } // namespace boost
105
106 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
107
108 #endif // BOOST_BIMAP_RELATION_SUPPORT_DATA_EXTRACTOR_HPP
109