]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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_CONCEPT_MAP_VALUE_HPP_JOFA_100924 | |
9 | #define BOOST_ICL_CONCEPT_MAP_VALUE_HPP_JOFA_100924 | |
10 | ||
11 | #include <boost/icl/type_traits/predicate.hpp> | |
12 | #include <boost/icl/type_traits/identity_element.hpp> | |
13 | #include <boost/icl/type_traits/is_map.hpp> | |
14 | ||
15 | namespace boost{ namespace icl | |
16 | { | |
17 | ||
18 | //============================================================================== | |
19 | //= AlgoUnifiers<Map> | |
20 | //============================================================================== | |
21 | template<class Type, class Iterator> | |
22 | inline typename enable_if<is_map<Type>, const typename Type::key_type>::type& | |
23 | key_value(Iterator it_) | |
24 | { | |
25 | return (*it_).first; | |
26 | } | |
27 | ||
28 | template<class Type, class Iterator> | |
29 | inline typename enable_if<is_map<Type>, const typename Type::codomain_type>::type& | |
30 | co_value(Iterator it_) | |
31 | { | |
32 | return (*it_).second; | |
33 | } | |
34 | ||
35 | template<class Type> | |
36 | inline typename enable_if<is_map<Type>, typename Type::value_type>::type | |
37 | make_value(const typename Type:: key_type& key_val, | |
38 | const typename Type::codomain_type& co_val) | |
39 | { | |
40 | return typename Type::value_type(key_val, co_val); | |
41 | } | |
42 | ||
43 | ||
44 | template <class Type> | |
45 | class content_is_identity_element: public property<Type> | |
46 | { | |
47 | public: | |
48 | bool operator() (const Type& value_pair)const | |
49 | { | |
50 | return value_pair.second | |
51 | == identity_element<typename Type::second_type>::value(); | |
52 | } | |
53 | } ; | |
54 | ||
55 | ||
56 | ||
57 | }} // namespace boost icl | |
58 | ||
59 | #endif | |
60 | ||
61 |