1 /* ///////////////////////////////////////////////////////////////////////
7 * Brief: add volatile-qualified traits
10 * Copyright (c) 2008-2020, Waruqi All rights reserved.
11 * //////////////////////////////////////////////////////////////////// */
12 #ifndef EXTL_TYPE_TRAITS_ADD_VOLATILE_H
13 #define EXTL_TYPE_TRAITS_ADD_VOLATILE_H
15 #ifndef EXTL_TYPE_TRAITS_ADD_VOLATILE_SUPPORT
16 # error extl::add_volatile is not supported by current compiler.
19 /* ///////////////////////////////////////////////////////////////////////
24 #ifdef EXTL_TYPE_TRAITS_IS_REF_SUPPORT
28 #ifdef EXTL_TYPE_TRAITS_TEST_ENABLE
29 # ifdef EXTL_TYPE_TRAITS_IS_VOLATILE_SUPPORT
30 # include "is_volatile.h"
34 /* ///////////////////////////////////////////////////////////////////////
37 #define EXTL_ADD_VOLATILE(src_type) EXTL_MODIFY_TYPE(add_volatile, src_type)
39 /* ///////////////////////////////////////////////////////////////////////
44 #ifdef EXTL_TYPE_TRAITS_SUPPORT
45 /* //////////////////////////////////////////////////////////////////// */
46 # ifdef EXTL_TEMPLATE_PARTIAL_SPEC_SUPPORT
47 EXTL_TYPE_TRAIT_DEF_1(add_volatile
, T
volatile)
49 // note: Cannot add volatile-qualified if T is reference
50 EXTL_TYPE_TRAIT_PARTIAL_SPEC_1_1(typename_param_k T
, add_volatile
, T
&, T
&)
52 template < e_bool_t is_ref
>
53 struct add_volatile_helper
55 template < typename_param_k T
>
62 EXTL_TEMPLATE_SPECIALISATION
63 struct add_volatile_helper
< e_false_v
>
65 template < typename_param_k T
>
68 typedef T
volatile type
;
72 template < typename_param_k T
>
73 struct add_volatile_impl
74 : add_volatile_helper
< (is_ref
<T
>::value
) >::template_qual_k result
<T
>
78 EXTL_TYPE_TRAIT_DEF_1(add_volatile
, typename_type_k add_volatile_impl
<T
>::type
)
82 /* ///////////////////////////////////////////////////////////////////////
85 # ifdef EXTL_TYPE_TRAITS_TEST_ENABLE
86 # include "unit_test/add_volatile_test.h"
90 /* ///////////////////////////////////////////////////////////////////////
95 /* //////////////////////////////////////////////////////////////////// */
96 #endif /* EXTL_TYPE_TRAITS_ADD_VOLATILE_H */
97 /* //////////////////////////////////////////////////////////////////// */