1/* Copyright 2003-2013 Joaquin M Lopez Munoz.
2 * Distributed under the Boost Software License, Version 1.0.
3 * (See accompanying file LICENSE_1_0.txt or copy at
4 * http://www.boost.org/LICENSE_1_0.txt)
5 *
6 * See http://www.boost.org/libs/multi_index for library home page.
7 */
8
9#ifndef BOOST_MULTI_INDEX_DETAIL_MODIFY_KEY_ADAPTOR_HPP
10#define BOOST_MULTI_INDEX_DETAIL_MODIFY_KEY_ADAPTOR_HPP
11
12#if defined(_MSC_VER)
13#pragma once
14#endif
15
16namespace boost{
17
18namespace multi_index{
19
20namespace detail{
21
22/* Functional adaptor to resolve modify_key as a call to modify.
23 * Preferred over compose_f_gx and stuff cause it eliminates problems
24 * with references to references, dealing with function pointers, etc.
25 */
26
27template<typename Fun,typename Value,typename KeyFromValue>
28struct modify_key_adaptor
29{
30
31 modify_key_adaptor(Fun f_,KeyFromValue kfv_):f(f_),kfv(kfv_){}
32
33 void operator()(Value& x)
34 {
35 f(kfv(x));
36 }
37
38private:
39 Fun f;
40 KeyFromValue kfv;
41};
42
43} /* namespace multi_index::detail */
44
45} /* namespace multi_index */
46
47} /* namespace boost */
48
49#endif
50