Skip to content

Commit 3caf754

Browse files
committed
Prefer static constexpr bool over std::true_type or std::false_type
1 parent 2a56a3a commit 3caf754

29 files changed

+118
-156
lines changed

include/boost/callable_traits/detail/default_callable_traits.hpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Distributed under the Boost Software License, Version 1.0.
99
#ifndef BOOST_CLBL_TRTS_DETAIL_DEFAULT_BOOST_CLBL_TRTS_HPP
1010
#define BOOST_CLBL_TRTS_DETAIL_DEFAULT_BOOST_CLBL_TRTS_HPP
1111

12+
#include <bits/types/error_t.h>
1213
namespace boost { namespace callable_traits { namespace detail {
1314

1415
template<typename T = void>
@@ -28,7 +29,7 @@ struct default_callable_traits {
2829
using type = error_t;
2930

3031
// std::true_type for callables with C-style variadics
31-
using has_varargs = std::false_type;
32+
static constexpr bool has_varargs = false;
3233

3334
using return_type = error_t;
3435

@@ -67,7 +68,7 @@ struct default_callable_traits {
6768

6869
// std::true_type when the signature includes noexcept, when
6970
// the feature is available
70-
using is_noexcept = std::false_type;
71+
static constexpr bool is_noexcept = false;
7172

7273
// adds noexcept to a signature if the feature is available
7374
using add_noexcept = error_t;
@@ -77,7 +78,7 @@ struct default_callable_traits {
7778

7879
// std::true_type when the signature includes transaction_safe, when
7980
// the feature is available
80-
using is_transaction_safe = std::false_type;
81+
static constexpr bool is_transaction_safe = false;
8182

8283
// adds transaction_safe to a signature if the feature is available
8384
using add_transaction_safe = error_t;
@@ -184,19 +185,19 @@ struct default_callable_traits {
184185
static constexpr qualifier_flags ref_flags = ref_of<T>::value;
185186
static constexpr qualifier_flags q_flags = cv_flags | ref_flags;
186187

187-
using has_member_qualifiers = std::integral_constant<bool, q_flags != default_>;
188-
using is_const_member = std::integral_constant<bool, 0 < (cv_flags & const_)>;
189-
using is_volatile_member = std::integral_constant<bool, 0 < (cv_flags & volatile_)>;
190-
using is_cv_member = std::integral_constant<bool, cv_flags == (const_ | volatile_)>;
188+
static constexpr bool has_member_qualifiers = q_flags != default_;
189+
static constexpr bool is_const_member = 0 < (cv_flags & const_);
190+
static constexpr bool is_volatile_member = 0 < (cv_flags & volatile_);
191+
static constexpr bool is_cv_member = cv_flags == (const_ | volatile_);
191192

192193
#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS
193-
using is_reference_member = std::false_type;
194-
using is_lvalue_reference_member = std::false_type;
195-
using is_rvalue_reference_member = std::false_type;
194+
static constexpr bool is_reference_member = false;
195+
static constexpr bool is_lvalue_reference_member = false;
196+
static constexpr bool is_rvalue_reference_member = false;
196197
#else
197-
using is_reference_member = std::integral_constant<bool, 0 < ref_flags>;
198-
using is_lvalue_reference_member = std::integral_constant<bool, ref_flags == lref_>;
199-
using is_rvalue_reference_member = std::integral_constant<bool, ref_flags == rref_>;
198+
static constexpr bool is_reference_member = 0 < ref_flags;
199+
static constexpr bool is_lvalue_reference_member = ref_flags == lref_;
200+
static constexpr bool is_rvalue_reference_member = ref_flags == rref_;
200201
#endif //#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS
201202

202203
};

include/boost/callable_traits/detail/function_object.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ struct function_object : Base {
3333
using invoke_type = error_t;
3434
using remove_varargs = error_t;
3535
using add_varargs = error_t;
36-
using is_noexcept = typename Base::is_noexcept;
36+
static constexpr bool is_noexcept = Base::is_noexcept;
3737
using add_noexcept = error_t;
3838
using remove_noexcept = error_t;
39-
using is_transaction_safe = typename Base::is_transaction_safe;
39+
static constexpr bool is_transaction_safe = Base::is_transaction_safe;
4040
using add_transaction_safe = error_t;
4141
using remove_transaction_safe = error_t;
4242
using clear_args = error_t;

include/boost/callable_traits/detail/is_invocable_impl.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ namespace boost { namespace callable_traits { namespace detail {
7272
using generalize_if_dissimilar = typename std::conditional<
7373
IsBaseOf::value || IsSame::value, T, generalize<T>>::type;
7474

75-
template<typename Traits, bool = Traits::is_const_member::value
76-
|| Traits::is_volatile_member::value
77-
|| Traits::is_lvalue_reference_member::value
78-
|| Traits::is_rvalue_reference_member::value>
75+
template<typename Traits, bool = Traits::is_const_member
76+
|| Traits::is_volatile_member
77+
|| Traits::is_lvalue_reference_member
78+
|| Traits::is_rvalue_reference_member>
7979
struct test_invoke {
8080

8181
template<typename... Rgs,

include/boost/callable_traits/detail/pmd.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ struct pmd<D T::*> : default_callable_traits<> {
4444

4545
template<template<class...> class Container>
4646
using expand_args = Container<invoke_type>;
47-
48-
using is_member_pointer = std::true_type;
4947
};
5048

5149
}}} // namespace boost::callable_traits::detail

include/boost/callable_traits/detail/unguarded/function.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ DO NOT INCLUDE THIS HEADER DIRECTLY
99
*/
1010

1111
#define BOOST_CLBL_TRTS_INCLUDE_TRANSACTION_SAFE
12-
#define BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE std::false_type
12+
#define BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE false
1313
#include <boost/callable_traits/detail/unguarded/function_2.hpp>
1414
#undef BOOST_CLBL_TRTS_INCLUDE_TRANSACTION_SAFE
1515
#undef BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE
1616

1717
#ifdef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE
18-
#define BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE std::true_type
18+
#define BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE true
1919
#define BOOST_CLBL_TRTS_INCLUDE_TRANSACTION_SAFE transaction_safe
2020
#include <boost/callable_traits/detail/unguarded/function_2.hpp>
2121
#undef BOOST_CLBL_TRTS_INCLUDE_TRANSACTION_SAFE
2222
#undef BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE
23-
#endif // #ifdef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE
23+
#endif // #ifdef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE

include/boost/callable_traits/detail/unguarded/function_2.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ DO NOT INCLUDE THIS HEADER DIRECTLY
99
*/
1010

1111
#define BOOST_CLBL_TRTS_NOEXCEPT_SPEC
12-
#define BOOST_CLBL_TRTS_IS_NOEXCEPT std::false_type
12+
#define BOOST_CLBL_TRTS_IS_NOEXCEPT false
1313
#include <boost/callable_traits/detail/unguarded/function_3.hpp>
1414
#undef BOOST_CLBL_TRTS_NOEXCEPT_SPEC
1515
#undef BOOST_CLBL_TRTS_IS_NOEXCEPT
1616

1717
#ifdef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES
1818
#define BOOST_CLBL_TRTS_NOEXCEPT_SPEC noexcept
19-
#define BOOST_CLBL_TRTS_IS_NOEXCEPT std::true_type
19+
#define BOOST_CLBL_TRTS_IS_NOEXCEPT true
2020
#include <boost/callable_traits/detail/unguarded/function_3.hpp>
2121
#undef BOOST_CLBL_TRTS_NOEXCEPT_SPEC
2222
#undef BOOST_CLBL_TRTS_IS_NOEXCEPT
23-
#endif // #ifdef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES
23+
#endif // #ifdef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES

include/boost/callable_traits/detail/unguarded/function_3.hpp

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS - the function-level qualifiers for the
1515
BOOST_CLBL_TRTS_INCLUDE_TRANSACTION_SAFE - the transaction_safe specifier for
1616
the current include (`transaction_safe` or nothing)
1717
18-
BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE - `std::true_type` or `std::false_type`,
18+
BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE - `true` or `false`,
1919
tied on whether BOOST_CLBL_TRTS_INCLUDE_TRANSACTION_SAFE is `transaction_safe`
2020
2121
BOOST_CLBL_TRTS_TRANSACTION_SAFE_SPECIFIER - `transaction_safe` when
@@ -24,7 +24,7 @@ BOOST_CLBL_TRTS_TRANSACTION_SAFE_SPECIFIER - `transaction_safe` when
2424
BOOST_CLBL_TRTS_NOEXCEPT_SPEC - the noexcept specifier for
2525
the current include (`noexcept` or nothing)
2626
27-
BOOST_CLBL_TRTS_IS_NOEXCEPT - `std::true_type` or `std::false_type`,
27+
BOOST_CLBL_TRTS_IS_NOEXCEPT - `true` or `false`,
2828
tied on whether BOOST_CLBL_TRTS_NOEXCEPT_SPEC is `noexcept`
2929
3030
BOOST_CLBL_TRTS_NOEXCEPT_SPECIFIER - `noexcept` if
@@ -67,7 +67,7 @@ struct function<Return(Args...)
6767
BOOST_CLBL_TRTS_INCLUDE_TRANSACTION_SAFE
6868
BOOST_CLBL_TRTS_NOEXCEPT_SPEC;
6969

70-
using is_noexcept = BOOST_CLBL_TRTS_IS_NOEXCEPT;
70+
static constexpr bool is_noexcept = BOOST_CLBL_TRTS_IS_NOEXCEPT;
7171

7272
using remove_noexcept = Return(Args...)
7373
BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
@@ -78,7 +78,7 @@ struct function<Return(Args...)
7878
BOOST_CLBL_TRTS_INCLUDE_TRANSACTION_SAFE
7979
BOOST_CLBL_TRTS_NOEXCEPT_SPECIFIER;
8080

81-
using is_transaction_safe = BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE;
81+
static constexpr bool is_transaction_safe = BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE;
8282

8383
using remove_transaction_safe = Return(Args...)
8484
BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
@@ -92,8 +92,8 @@ struct function<Return(Args...)
9292
using qualifiers = default_callable_traits<dummy BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS>;
9393

9494
template<qualifier_flags Flags>
95-
using set_qualifiers = set_function_qualifiers<Flags, is_transaction_safe::value,
96-
is_noexcept::value, Return, Args...>;
95+
using set_qualifiers = set_function_qualifiers<Flags, is_transaction_safe,
96+
is_noexcept, Return, Args...>;
9797

9898
#ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS
9999

@@ -140,8 +140,6 @@ struct function<Return(Args...)
140140

141141
template<template<class...> class Container>
142142
using expand_args = Container<Args...>;
143-
144-
using is_member_pointer = std::false_type;
145143
};
146144

147145

@@ -154,7 +152,7 @@ struct function<Return (Args..., ...)
154152

155153
static constexpr bool value = true;
156154

157-
using has_varargs = std::true_type;
155+
static constexpr bool has_varargs = true;
158156
using traits = function;
159157
using return_type = Return;
160158
using arg_types = std::tuple<Args...>;
@@ -178,7 +176,7 @@ struct function<Return (Args..., ...)
178176

179177
using add_varargs = type;
180178

181-
using is_noexcept = BOOST_CLBL_TRTS_IS_NOEXCEPT;
179+
static constexpr bool is_noexcept = BOOST_CLBL_TRTS_IS_NOEXCEPT;
182180

183181
using remove_noexcept = Return(Args..., ...)
184182
BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
@@ -189,7 +187,7 @@ struct function<Return (Args..., ...)
189187
BOOST_CLBL_TRTS_INCLUDE_TRANSACTION_SAFE
190188
BOOST_CLBL_TRTS_NOEXCEPT_SPECIFIER;
191189

192-
using is_transaction_safe = BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE;
190+
static constexpr bool is_transaction_safe = BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE;
193191

194192
using remove_transaction_safe = Return(Args..., ...)
195193
BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
@@ -203,8 +201,8 @@ struct function<Return (Args..., ...)
203201
using qualifiers = default_callable_traits<dummy BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS>;
204202

205203
template<qualifier_flags Flags>
206-
using set_qualifiers = set_varargs_function_qualifiers<Flags, is_transaction_safe::value,
207-
is_noexcept::value, Return, Args...>;
204+
using set_qualifiers = set_varargs_function_qualifiers<Flags, is_transaction_safe,
205+
is_noexcept, Return, Args...>;
208206

209207
#ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS
210208

@@ -255,6 +253,4 @@ struct function<Return (Args..., ...)
255253

256254
template<template<class...> class Container>
257255
using expand_args = Container<Args...>;
258-
259-
using is_member_pointer = std::false_type;
260256
};

include/boost/callable_traits/detail/unguarded/function_ptr.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ DO NOT INCLUDE THIS HEADER DIRECTLY
99
*/
1010

1111
#define BOOST_CLBL_TRTS_INCLUDE_TRANSACTION_SAFE
12-
#define BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE std::false_type
12+
#define BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE false
1313
#include <boost/callable_traits/detail/unguarded/function_ptr_2.hpp>
1414

1515
#undef BOOST_CLBL_TRTS_INCLUDE_TRANSACTION_SAFE
1616
#undef BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE
1717

1818
#ifdef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE
19-
#define BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE std::true_type
19+
#define BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE true
2020
#define BOOST_CLBL_TRTS_INCLUDE_TRANSACTION_SAFE transaction_safe
2121
#include <boost/callable_traits/detail/unguarded/function_ptr_2.hpp>
2222
#endif

include/boost/callable_traits/detail/unguarded/function_ptr_2.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ DO NOT INCLUDE THIS HEADER DIRECTLY
99
*/
1010

1111
#define BOOST_CLBL_TRTS_NOEXCEPT_SPEC
12-
#define BOOST_CLBL_TRTS_IS_NOEXCEPT std::false_type
12+
#define BOOST_CLBL_TRTS_IS_NOEXCEPT false
1313
#include <boost/callable_traits/detail/unguarded/function_ptr_3.hpp>
1414
#undef BOOST_CLBL_TRTS_NOEXCEPT_SPEC
1515
#undef BOOST_CLBL_TRTS_IS_NOEXCEPT
1616

1717
#ifdef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES
1818
#define BOOST_CLBL_TRTS_NOEXCEPT_SPEC noexcept
19-
#define BOOST_CLBL_TRTS_IS_NOEXCEPT std::true_type
19+
#define BOOST_CLBL_TRTS_IS_NOEXCEPT true
2020
#include <boost/callable_traits/detail/unguarded/function_ptr_3.hpp>
2121
#undef BOOST_CLBL_TRTS_NOEXCEPT_SPEC
2222
#undef BOOST_CLBL_TRTS_IS_NOEXCEPT
23-
#endif // #ifdef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES
23+
#endif // #ifdef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES

include/boost/callable_traits/detail/unguarded/function_ptr_3.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ macros used:
1212
BOOST_CLBL_TRTS_INCLUDE_TRANSACTION_SAFE - the transaction_safe specifier for
1313
the current include (`transaction_safe` or nothing)
1414
15-
BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE - `std::true_type` or `std::false_type`,
15+
BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE - `true` or `false`,
1616
tied on whether BOOST_CLBL_TRTS_INCLUDE_TRANSACTION_SAFE is `transaction_safe`
1717
1818
BOOST_CLBL_TRTS_TRANSACTION_SAFE_SPECIFIER - `transaction_safe` when
@@ -21,7 +21,7 @@ BOOST_CLBL_TRTS_TRANSACTION_SAFE_SPECIFIER - `transaction_safe` when
2121
BOOST_CLBL_TRTS_NOEXCEPT_SPEC - the noexcept specifier for
2222
the current include (`noexcept` or nothing)
2323
24-
BOOST_CLBL_TRTS_IS_NOEXCEPT - `std::true_type` or `std::false_type`,
24+
BOOST_CLBL_TRTS_IS_NOEXCEPT - `true` or `false`,
2525
tied on whether BOOST_CLBL_TRTS_NOEXCEPT_SPEC is `noexcept`
2626
2727
BOOST_CLBL_TRTS_NOEXCEPT_SPECIFIER - `noexcept` if
@@ -56,7 +56,7 @@ struct function<
5656
BOOST_CLBL_TRTS_INCLUDE_TRANSACTION_SAFE
5757
BOOST_CLBL_TRTS_NOEXCEPT_SPEC;
5858

59-
using is_noexcept = BOOST_CLBL_TRTS_IS_NOEXCEPT;
59+
static constexpr bool is_noexcept = BOOST_CLBL_TRTS_IS_NOEXCEPT;
6060

6161
using remove_noexcept = Return(BOOST_CLBL_TRTS_CC *)(Args...)
6262
BOOST_CLBL_TRTS_INCLUDE_TRANSACTION_SAFE;
@@ -65,7 +65,7 @@ struct function<
6565
BOOST_CLBL_TRTS_INCLUDE_TRANSACTION_SAFE
6666
BOOST_CLBL_TRTS_NOEXCEPT_SPECIFIER;
6767

68-
using is_transaction_safe = BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE;
68+
static constexpr bool is_transaction_safe = BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE;
6969

7070
using remove_transaction_safe = Return(BOOST_CLBL_TRTS_CC *)(Args...)
7171
BOOST_CLBL_TRTS_NOEXCEPT_SPEC;
@@ -88,7 +88,5 @@ struct function<
8888

8989
template<template<class...> class Container>
9090
using expand_args = Container<Args...>;
91-
92-
using is_member_pointer = std::false_type;
9391
};
9492

0 commit comments

Comments
 (0)