Chris@16
|
1
|
Chris@16
|
2 // Copyright (C) 2009-2012 Lorenzo Caminiti
|
Chris@16
|
3 // Distributed under the Boost Software License, Version 1.0
|
Chris@16
|
4 // (see accompanying file LICENSE_1_0.txt or a copy at
|
Chris@16
|
5 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 // Home at http://www.boost.org/libs/local_function
|
Chris@16
|
7
|
Chris@16
|
8 #ifndef BOOST_LOCAL_FUNCTION_AUX_MEMBER_HPP_
|
Chris@16
|
9 #define BOOST_LOCAL_FUNCTION_AUX_MEMBER_HPP_
|
Chris@16
|
10
|
Chris@16
|
11 namespace boost { namespace local_function { namespace aux {
|
Chris@16
|
12
|
Chris@16
|
13 // Metafunctions to manipulate data members.
|
Chris@16
|
14
|
Chris@16
|
15 template<typename T> struct member_type {
|
Chris@16
|
16 typedef T& reference;
|
Chris@16
|
17 typedef T* pointer;
|
Chris@16
|
18 };
|
Chris@16
|
19
|
Chris@16
|
20 template<typename T> struct member_type<T*> {
|
Chris@16
|
21 typedef T*& reference;
|
Chris@16
|
22 typedef T* pointer;
|
Chris@16
|
23 };
|
Chris@16
|
24
|
Chris@16
|
25 template<typename T> struct member_type<T* const> {
|
Chris@16
|
26 typedef T* const& reference;
|
Chris@16
|
27 typedef T* pointer;
|
Chris@16
|
28 };
|
Chris@16
|
29
|
Chris@16
|
30 template<typename T> struct member_type<T const*> {
|
Chris@16
|
31 typedef T const*& reference;
|
Chris@16
|
32 typedef T const* pointer;
|
Chris@16
|
33 };
|
Chris@16
|
34
|
Chris@16
|
35 template<typename T> struct member_type<T const* const> {
|
Chris@16
|
36 typedef T const* const& reference;
|
Chris@16
|
37 typedef T const* pointer;
|
Chris@16
|
38 };
|
Chris@16
|
39
|
Chris@16
|
40 // NOTE: Do not add specializations for T const[&/*] (ambiguous on VACPP).
|
Chris@16
|
41 template<typename T> T* member_addr(T& data) { return &data; }
|
Chris@16
|
42 template<typename T> T* member_addr(T* data) { return data; }
|
Chris@16
|
43
|
Chris@16
|
44 // NOTE: Do not add specializations for T const[&/*] (ambiguous on VACPP).
|
Chris@16
|
45 template<typename T> T& member_deref(T& data) { return data; }
|
Chris@16
|
46 template<typename T> T& member_deref(T* data) { return *data; }
|
Chris@16
|
47
|
Chris@16
|
48 } } } // namespace
|
Chris@16
|
49
|
Chris@16
|
50 #endif // #include guard
|
Chris@16
|
51
|