remove \r
[extl.git] / extl / type / traits / add_ptr.h
blobc6066a0001aa27f9e7d04349e64541181428a6dd
1 /* ///////////////////////////////////////////////////////////////////////
2 * File: add_ptr.h
4 * Created: 08.02.07
5 * Updated: 08.07.09
7 * Brief: add pointer traits
9 * [<Home>]
10 * Copyright (c) 2008-2020, Waruqi All rights reserved.
11 * //////////////////////////////////////////////////////////////////// */
12 #ifndef EXTL_TYPE_TRAITS_ADD_PTR_H
13 #define EXTL_TYPE_TRAITS_ADD_PTR_H
15 /* ///////////////////////////////////////////////////////////////////////
16 * Includes
18 #include "prefix.h"
20 #ifdef EXTL_TYPE_TRAITS_IS_REF_SUPPORT
21 # include "is_ref.h"
22 #endif
24 #ifdef EXTL_TYPE_TRAITS_REMOVE_REF_SUPPORT
25 # include "remove_ref.h"
26 #endif
28 #ifdef EXTL_TYPE_TRAITS_TEST_ENABLE
29 # ifdef EXTL_TYPE_TRAITS_IS_PTR_SUPPORT
30 # include "is_ptr.h"
31 # endif
32 #endif
34 /* ///////////////////////////////////////////////////////////////////////
35 * Macros
37 #define EXTL_ADD_PTR(src_type) EXTL_MODIFY_TYPE(add_ptr, src_type)
39 /* ///////////////////////////////////////////////////////////////////////
40 * ::extl namespace
42 EXTL_BEGIN_NAMESPACE
44 #ifdef EXTL_TYPE_TRAITS_SUPPORT
46 # ifdef EXTL_TYPE_TRAITS_REMOVE_REF_SUPPORT
47 EXTL_TYPE_TRAIT_DEF_1(add_ptr, typename_type_k remove_ref<T>::type*)
48 # else
50 template < e_bool_t is_ref >
51 struct add_ptr_helper
53 template < typename_param_k T>
54 struct result
56 typedef T type;
60 EXTL_TEMPLATE_SPECIALISATION
61 struct add_ptr_helper< e_false_v >
63 template < typename_param_k T>
64 struct result
66 typedef T* type;
70 template < typename_param_k T >
71 struct add_ptr_impl
72 : add_ptr_helper< (is_ref<T>::value) >::template_qual_k result<T>
77 EXTL_TYPE_TRAIT_DEF_1(add_ptr, typename_type_k add_ptr_impl<T>::type)
79 # endif
81 /* ///////////////////////////////////////////////////////////////////////
82 * Unit-testing
84 # ifdef EXTL_TYPE_TRAITS_TEST_ENABLE
85 # include "unit_test/add_ptr_test.h"
86 # endif
88 #endif
90 /* ///////////////////////////////////////////////////////////////////////
91 * ::extl namespace
93 EXTL_END_NAMESPACE
95 /* //////////////////////////////////////////////////////////////////// */
96 #endif /* EXTL_TYPE_TRAITS_ADD_PTR_H */
97 /* //////////////////////////////////////////////////////////////////// */