[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 4427d76 12/12: C++17-ize
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 4427d76 12/12: C++17-ize |
Date: |
Sat, 24 Oct 2020 16:51:36 -0400 (EDT) |
branch: master
commit 4427d76b0d8ca7269bbc8d08ed914e23f0e84ea0
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
C++17-ize
Replaced 'is_X<...>::value' with 'is_X_v<...>'.
---
alert.cpp | 2 +-
callback.hpp | 4 ++--
contains.hpp | 5 ++++-
contains_test.cpp | 10 ++++++++++
ieee754.hpp | 6 +++---
input_sequence.cpp | 4 ++--
input_sequence_aux.hpp | 2 +-
math_functions.hpp | 20 ++++++++++----------
math_functions_test.cpp | 14 +++++++-------
mc_enum.hpp | 2 +-
multidimgrid_safe.hpp | 2 +-
multidimgrid_tools.hpp | 2 +-
mvc_controller.tpp | 4 ++--
numeric_io_cast.hpp | 8 ++++----
numeric_io_traits.hpp | 2 +-
round_to.hpp | 2 +-
safely_dereference_as.hpp | 2 +-
stream_cast.hpp | 6 +++---
tn_range.hpp | 2 +-
tn_range.tpp | 19 ++++++++++---------
tn_range_test.cpp | 2 +-
tn_range_type_trammels.hpp | 2 +-
value_cast.hpp | 21 ++++++++++++---------
value_cast_test.cpp | 28 ++++++++++++++--------------
view_ex.tpp | 2 +-
wx_utility.hpp | 6 +++---
xml_serializable.tpp | 8 ++++----
xml_serialize.hpp | 10 +++++-----
28 files changed, 107 insertions(+), 90 deletions(-)
diff --git a/alert.cpp b/alert.cpp
index b1c6469..cab4db6 100644
--- a/alert.cpp
+++ b/alert.cpp
@@ -191,7 +191,7 @@ class alarum_buf
template<typename T>
inline std::ostream& alert_stream()
{
- static_assert(std::is_base_of<alert_buf,T>::value);
+ static_assert(std::is_base_of_v<alert_buf,T>);
static T buffer_;
static std::ostream stream_(&buffer_);
stream_.clear();
diff --git a/callback.hpp b/callback.hpp
index d8f62e0..d13926d 100644
--- a/callback.hpp
+++ b/callback.hpp
@@ -96,9 +96,9 @@
template<typename FunctionPointer>
class LMI_SO callback final
{
- static_assert(std::is_pointer<FunctionPointer>::value);
+ static_assert(std::is_pointer_v<FunctionPointer>);
typedef typename std::remove_pointer<FunctionPointer>::type f_type;
- static_assert(std::is_function<f_type>::value);
+ static_assert(std::is_function_v<f_type>);
public:
callback() = default;
diff --git a/contains.hpp b/contains.hpp
index ca4aba0..9ac6d3d 100644
--- a/contains.hpp
+++ b/contains.hpp
@@ -56,6 +56,9 @@ struct has_member_find
static bool const value = sizeof(yea_t) == sizeof
deduce(static_cast<Derived*>(nullptr));
};
+template<typename T>
+inline constexpr bool has_member_find_v = has_member_find<T>::value;
+
/// Ascertain whether a "container" includes a given element.
///
/// Here, std::basic_string is considered a "container", this:
@@ -69,7 +72,7 @@ template<typename T>
bool contains
(T const& t
,typename T::value_type const& element
- ,typename std::enable_if<!has_member_find<T>::value>::type* = nullptr
+ ,typename std::enable_if<!has_member_find_v<T>>::type* = nullptr
)
{
return t.end() != std::find(t.begin(), t.end(), element);
diff --git a/contains_test.cpp b/contains_test.cpp
index 5294c70..d1af4cf 100644
--- a/contains_test.cpp
+++ b/contains_test.cpp
@@ -46,6 +46,16 @@ void test_has_member_find()
static_assert( has_member_find<std::map <int,int>>::value);
static_assert( has_member_find<std::set <int >>::value);
static_assert(!has_member_find<std::vector<int >>::value);
+
+ // same, with has_member_find_v
+ static_assert( has_member_find_v<HasFind >);
+ static_assert(!has_member_find_v<LacksFind>);
+
+ static_assert( has_member_find_v<std::string>);
+
+ static_assert( has_member_find_v<std::map <int,int>>);
+ static_assert( has_member_find_v<std::set <int >>);
+ static_assert(!has_member_find_v<std::vector<int >>);
}
/// Test standard "containers" for which find() makes sense.
diff --git a/ieee754.hpp b/ieee754.hpp
index 6e81c3e..f589872 100644
--- a/ieee754.hpp
+++ b/ieee754.hpp
@@ -43,7 +43,7 @@
template<typename T>
T implausible_value(T const& t = -9.99999e35f)
{
- static_assert(::std::is_floating_point<T>::value);
+ static_assert(::std::is_floating_point_v<T>);
if(std::numeric_limits<T>::has_quiet_NaN)
{
@@ -71,7 +71,7 @@ T implausible_value(T const& t = -9.99999e35f)
template<typename T>
inline T infinity()
{
- static_assert(::std::is_floating_point<T>::value);
+ static_assert(::std::is_floating_point_v<T>);
static_assert(std::numeric_limits<T>::has_infinity);
static T const volatile z = std::numeric_limits<T>::infinity();
return z;
@@ -103,7 +103,7 @@ inline T infinity()
template<typename T>
inline bool is_infinite(T t)
{
- static_assert(::std::is_floating_point<T>::value);
+ static_assert(::std::is_floating_point_v<T>);
static T const volatile pos_inf = std::numeric_limits<T>::infinity();
static T const volatile neg_inf = -std::numeric_limits<T>::infinity();
static bool const has_inf = std::numeric_limits<T>::has_infinity;
diff --git a/input_sequence.cpp b/input_sequence.cpp
index dfb5ded..6e86041 100644
--- a/input_sequence.cpp
+++ b/input_sequence.cpp
@@ -212,8 +212,8 @@ void set_value(ValueInterval& v, std::string const& s)
template<typename T>
void InputSequence::initialize_from_vector(std::vector<T> const& v)
{
- bool const T_is_double = std::is_same<T,double >::value;
- bool const T_is_string = std::is_same<T,std::string>::value;
+ bool const T_is_double = std::is_same_v<T,double >;
+ bool const T_is_string = std::is_same_v<T,std::string>;
static_assert(T_is_double || T_is_string);
ValueInterval default_interval;
diff --git a/input_sequence_aux.hpp b/input_sequence_aux.hpp
index b287381..28bce86 100644
--- a/input_sequence_aux.hpp
+++ b/input_sequence_aux.hpp
@@ -105,7 +105,7 @@ namespace detail
template<typename T>
std::vector<T> convert_vector_type
(std::vector<mc_enum<T>> const& ve
- ,typename std::enable_if<std::is_enum<T>::value>::type* = nullptr
+ ,typename std::enable_if<std::is_enum_v<T>>::type* = nullptr
)
{
std::vector<T> z;
diff --git a/math_functions.hpp b/math_functions.hpp
index b186fa6..f219974 100644
--- a/math_functions.hpp
+++ b/math_functions.hpp
@@ -86,7 +86,7 @@ struct mean
using first_argument_type = T;
using second_argument_type = T;
using result_type = T;
- static_assert(std::is_floating_point<T>::value);
+ static_assert(std::is_floating_point_v<T>);
T operator()(T const& x, T const& y) const
{return 0.5 * x + 0.5 * y;}
};
@@ -100,7 +100,7 @@ struct mean
template<typename T>
inline T outward_quotient(T numerator, T denominator)
{
- static_assert(std::is_integral<T>::value);
+ static_assert(std::is_integral_v<T>);
LMI_ASSERT(0 != denominator);
@@ -138,7 +138,7 @@ inline T outward_quotient(T numerator, T denominator)
template<typename T, int n>
struct i_upper_n_over_n_from_i
{
- static_assert(std::is_floating_point<T>::value);
+ static_assert(std::is_floating_point_v<T>);
static_assert(0 < n);
T operator()(T const& i) const
{
@@ -165,7 +165,7 @@ struct i_upper_12_over_12_from_i
{
using argument_type = T;
using result_type = T;
- static_assert(std::is_floating_point<T>::value);
+ static_assert(std::is_floating_point_v<T>);
T operator()(T const& i) const
{
return i_upper_n_over_n_from_i<T,12>()(i);
@@ -175,7 +175,7 @@ struct i_upper_12_over_12_from_i
template<typename T, int n>
struct i_from_i_upper_n_over_n
{
- static_assert(std::is_floating_point<T>::value);
+ static_assert(std::is_floating_point_v<T>);
static_assert(0 < n);
T operator()(T const& i) const
{
@@ -189,7 +189,7 @@ struct i_from_i_upper_n_over_n
template<typename T>
struct i_from_i_upper_12_over_12
{
- static_assert(std::is_floating_point<T>::value);
+ static_assert(std::is_floating_point_v<T>);
T operator()(T const& i) const
{
return i_from_i_upper_n_over_n<T,12>()(i);
@@ -199,7 +199,7 @@ struct i_from_i_upper_12_over_12
template<typename T, int n>
struct d_upper_n_from_i
{
- static_assert(std::is_floating_point<T>::value);
+ static_assert(std::is_floating_point_v<T>);
static_assert(0 < n);
T operator()(T const& i) const
{
@@ -224,7 +224,7 @@ struct d_upper_n_from_i
template<typename T>
struct d_upper_12_from_i
{
- static_assert(std::is_floating_point<T>::value);
+ static_assert(std::is_floating_point_v<T>);
T operator()(T const& i) const
{
return d_upper_n_from_i<T,12>()(i);
@@ -240,7 +240,7 @@ struct d_upper_12_from_i
template<typename T, int n>
struct net_i_from_gross
{
- static_assert(std::is_floating_point<T>::value);
+ static_assert(std::is_floating_point_v<T>);
static_assert(0 < n);
T operator()(T const& i, T const& spread, T const& fee) const
{
@@ -293,7 +293,7 @@ struct coi_rate_from_q
using first_argument_type = T;
using second_argument_type = T;
using result_type = T;
- static_assert(std::is_floating_point<T>::value);
+ static_assert(std::is_floating_point_v<T>);
T operator()(T const& q, T const& max_coi) const
{
if(!(0.0 <= max_coi && max_coi <= 1.0))
diff --git a/math_functions_test.cpp b/math_functions_test.cpp
index b44d4aa..a21285c 100644
--- a/math_functions_test.cpp
+++ b/math_functions_test.cpp
@@ -47,7 +47,7 @@ namespace
template<typename T>
struct i_upper_12_over_12_from_i_naive
{
- static_assert(std::is_floating_point<T>::value);
+ static_assert(std::is_floating_point_v<T>);
T operator()(T const& i) const
{
long double z = -1.0L + std::pow((1.0L + i), 1.0L / 12.0L);
@@ -58,7 +58,7 @@ struct i_upper_12_over_12_from_i_naive
template<typename T>
struct i_from_i_upper_12_over_12_naive
{
- static_assert(std::is_floating_point<T>::value);
+ static_assert(std::is_floating_point_v<T>);
T operator()(T const& i) const
{
long double z = -1.0L + std::pow((1.0L + i), 12.0L);
@@ -69,7 +69,7 @@ struct i_from_i_upper_12_over_12_naive
template<typename T>
struct d_upper_12_from_i_naive
{
- static_assert(std::is_floating_point<T>::value);
+ static_assert(std::is_floating_point_v<T>);
T operator()(T const& i) const
{
long double z = 12.0L * (1.0L - std::pow(1.0L + i, -1.0L / 12.0L));
@@ -80,7 +80,7 @@ struct d_upper_12_from_i_naive
template<typename T, int n>
struct net_i_from_gross_naive
{
- static_assert(std::is_floating_point<T>::value);
+ static_assert(std::is_floating_point_v<T>);
T operator()(T const& i, T const& spread, T const& fee) const
{
static long double const reciprocal_n = 1.0L / n;
@@ -99,7 +99,7 @@ struct net_i_from_gross_naive
template<typename T>
struct coi_rate_from_q_naive
{
- static_assert(std::is_floating_point<T>::value);
+ static_assert(std::is_floating_point_v<T>);
T operator()(T const& q, T const& max_coi) const
{
if(0.0 == q)
@@ -124,7 +124,7 @@ struct coi_rate_from_q_naive
template<typename T, int n>
struct i_upper_n_over_n_from_i_naive
{
- static_assert(std::is_floating_point<T>::value);
+ static_assert(std::is_floating_point_v<T>);
T operator()(T const& i) const
{
return T(-1) + std::pow((T(1) + i), T(1) / n);
@@ -137,7 +137,7 @@ struct i_upper_n_over_n_from_i_naive
template<typename T, int n>
struct i_upper_n_over_n_from_i_T
{
- static_assert(std::is_floating_point<T>::value);
+ static_assert(std::is_floating_point_v<T>);
T operator()(T const& i) const
{
static T const reciprocal_n = T(1) / n;
diff --git a/mc_enum.hpp b/mc_enum.hpp
index d0807e9..e34c2c3 100644
--- a/mc_enum.hpp
+++ b/mc_enum.hpp
@@ -92,7 +92,7 @@ template<typename T>
class mc_enum final
:public mc_enum_base
{
- static_assert(std::is_enum<T>::value);
+ static_assert(std::is_enum_v<T>);
friend class mc_enum_test;
template<typename U> friend std::vector<std::string> const& all_strings();
diff --git a/multidimgrid_safe.hpp b/multidimgrid_safe.hpp
index b34723c..42d709c 100644
--- a/multidimgrid_safe.hpp
+++ b/multidimgrid_safe.hpp
@@ -258,7 +258,7 @@ template<typename AdjustControl, typename BaseAxisType =
MultiDimAxisAny>
class MultiDimAdjustableAxis
:public BaseAxisType
{
- static_assert(std::is_base_of<MultiDimAxisAny,BaseAxisType>::value);
+ static_assert(std::is_base_of_v<MultiDimAxisAny,BaseAxisType>);
protected:
typedef AdjustControl AxisAdjustControl;
diff --git a/multidimgrid_tools.hpp b/multidimgrid_tools.hpp
index 85bc8c7..37c0591 100644
--- a/multidimgrid_tools.hpp
+++ b/multidimgrid_tools.hpp
@@ -88,7 +88,7 @@ template<typename Integral>
class AxisMaxBoundAdjuster
:public AxisMaxBoundAdjusterBase
{
- static_assert(std::is_integral<Integral>::value);
+ static_assert(std::is_integral_v<Integral>);
public:
AxisMaxBoundAdjuster
diff --git a/mvc_controller.tpp b/mvc_controller.tpp
index c368082..e02278e 100644
--- a/mvc_controller.tpp
+++ b/mvc_controller.tpp
@@ -69,8 +69,8 @@ T const& MvcController::ModelReference(std::string const&
name) const
template<typename T>
T& MvcController::WindowFromXrcName(char const* name) const
{
- static_assert(!std::is_pointer<T>::value);
- static_assert(std::is_base_of<wxWindow,T>::value);
+ static_assert(!std::is_pointer_v<T>);
+ static_assert(std::is_base_of_v<wxWindow,T>);
wxWindow* w = FindWindow(wxXmlResource::GetXRCID(name));
if(!w)
diff --git a/numeric_io_cast.hpp b/numeric_io_cast.hpp
index beebed8..5418960 100644
--- a/numeric_io_cast.hpp
+++ b/numeric_io_cast.hpp
@@ -117,8 +117,8 @@ To numeric_io_cast(From from, To = To())
template<typename To, typename From>
struct numeric_converter
{
- static_assert(std::is_void<To >::value);
- static_assert(std::is_void<From>::value);
+ static_assert(std::is_void_v<To >);
+ static_assert(std::is_void_v<From>);
To operator()(From const&) const
{
@@ -132,7 +132,7 @@ struct numeric_converter
template<typename To>
struct numeric_converter<To, std::string>
{
- static_assert(std::is_arithmetic<To>::value);
+ static_assert(std::is_arithmetic_v<To>);
typedef std::string From;
To operator()(From const& from) const
@@ -201,7 +201,7 @@ struct numeric_converter<To, char const*>
template<typename From>
struct numeric_converter<std::string, From>
{
- static_assert(std::is_arithmetic<From>::value);
+ static_assert(std::is_arithmetic_v<From>);
typedef std::string To;
To operator()(From const& from) const
diff --git a/numeric_io_traits.hpp b/numeric_io_traits.hpp
index 321cfc2..bb8e98e 100644
--- a/numeric_io_traits.hpp
+++ b/numeric_io_traits.hpp
@@ -59,7 +59,7 @@
template<typename T>
inline int floating_point_decimals(T t)
{
- static_assert(std::is_floating_point<T>::value);
+ static_assert(std::is_floating_point_v<T>);
#if defined LMI_MSVCRT
// COMPILER !! This C runtime not only writes infinity as "1.#INF"
// instead of "inf" but also "respects" the precision specifier
diff --git a/round_to.hpp b/round_to.hpp
index 0996f6b..fed8f88 100644
--- a/round_to.hpp
+++ b/round_to.hpp
@@ -252,7 +252,7 @@ RealType erroneous_rounding_function(RealType)
template<typename RealType>
class round_to
{
- static_assert(std::is_floating_point<RealType>::value);
+ static_assert(std::is_floating_point_v<RealType>);
public:
/// The default ctor only makes the class DefaultConstructible;
diff --git a/safely_dereference_as.hpp b/safely_dereference_as.hpp
index d0a5ac4..1c47638 100644
--- a/safely_dereference_as.hpp
+++ b/safely_dereference_as.hpp
@@ -68,7 +68,7 @@
template<typename T, typename U>
T& safely_dereference_as(U* u)
{
- static_assert(std::is_base_of<U,T>::value);
+ static_assert(std::is_base_of_v<U,T>);
if(!u)
{
std::ostringstream oss;
diff --git a/stream_cast.hpp b/stream_cast.hpp
index e57d689..ddb4ebd 100644
--- a/stream_cast.hpp
+++ b/stream_cast.hpp
@@ -99,10 +99,10 @@ template<typename To, typename From>
To stream_cast(From from, To = To())
{
static_assert
- ( !std::is_arithmetic<From>::value
- || !std::is_arithmetic<To >::value
+ ( !std::is_arithmetic_v<From>
+ || !std::is_arithmetic_v<To >
);
- static_assert(!std::is_pointer<To>::value);
+ static_assert(!std::is_pointer_v<To>);
auto complain = [&](auto const& reason)
{
diff --git a/tn_range.hpp b/tn_range.hpp
index 1a14a5a..43ecb92 100644
--- a/tn_range.hpp
+++ b/tn_range.hpp
@@ -229,7 +229,7 @@ template<typename Number, typename Trammel>
class tn_range final
:public tn_range_base
{
- static_assert(std::is_base_of<trammel_base<Number>,Trammel>::value);
+ static_assert(std::is_base_of_v<trammel_base<Number>,Trammel>);
friend class tn_range_test;
diff --git a/tn_range.tpp b/tn_range.tpp
index d4367d7..59661aa 100644
--- a/tn_range.tpp
+++ b/tn_range.tpp
@@ -30,6 +30,7 @@
#include <limits>
#include <ostream>
#include <sstream>
+#include <type_traits>
namespace
{
@@ -53,7 +54,7 @@ namespace
template
<typename T
,bool=std::numeric_limits<T>::is_specialized
- ,bool=std::is_floating_point<T>::value
+ ,bool=std::is_floating_point_v<T>
>
struct strictly_between_extrema_tester
{};
@@ -108,7 +109,7 @@ namespace
template<typename T>
T signum(T t)
{
- static_assert(std::is_arithmetic<T>::value);
+ static_assert(std::is_arithmetic_v<T>);
return (0 == t) ? 0 : std::signbit(t) ? -1 : 1;
}
@@ -166,7 +167,7 @@ namespace
/// http://groups.google.com/groups?th=1b868327b241fb74
/// http://groups.google.com/groups?selm=3DF66B8D.F1C3D2C0%40sun.com
- template<typename T, bool=std::is_floating_point<T>::value>
+ template<typename T, bool=std::is_floating_point_v<T>>
struct is_exact_integer_tester
{};
@@ -179,7 +180,7 @@ namespace
template<typename T>
struct is_exact_integer_tester<T,true>
{
- static_assert(std::is_floating_point<T>::value);
+ static_assert(std::is_floating_point_v<T>);
bool operator()(T t)
{
// SOMEDAY !! nonstd::power() [SGI extension] may be
@@ -218,7 +219,7 @@ namespace
template<typename T>
T adjust_bound(T t, T direction)
{
- static_assert(std::is_floating_point<T>::value);
+ static_assert(std::is_floating_point_v<T>);
if(is_exact_integer(t))
{
return t;
@@ -261,7 +262,7 @@ namespace
template<typename T>
struct bound_adjuster<T,-1>
{
- static_assert(std::is_floating_point<T>::value);
+ static_assert(std::is_floating_point_v<T>);
T operator()(T t)
{
static T const extremum = -std::numeric_limits<T>::max();
@@ -272,7 +273,7 @@ namespace
template<typename T>
struct bound_adjuster<T,1>
{
- static_assert(std::is_floating_point<T>::value);
+ static_assert(std::is_floating_point_v<T>);
T operator()(T t)
{
static T const extremum = std::numeric_limits<T>::max();
@@ -283,13 +284,13 @@ namespace
template<typename T>
T adjust_minimum(T t)
{
- return bound_adjuster<T,std::is_floating_point<T>::value ? -1 :
0>()(t);
+ return bound_adjuster<T,std::is_floating_point_v<T> ? -1 : 0>()(t);
}
template<typename T>
T adjust_maximum(T t)
{
- return bound_adjuster<T,std::is_floating_point<T>::value ? 1 : 0>()(t);
+ return bound_adjuster<T,std::is_floating_point_v<T> ? 1 : 0>()(t);
}
} // Unnamed namespace.
diff --git a/tn_range_test.cpp b/tn_range_test.cpp
index 80198fa..5254bc4 100644
--- a/tn_range_test.cpp
+++ b/tn_range_test.cpp
@@ -138,7 +138,7 @@ void tn_range_test::test_auxiliary_functions(char const*
file, int line)
T const minT = std::numeric_limits<T>::lowest();
INVOKE_BOOST_TEST(!is_strictly_between_extrema(maxT), file, line);
- if(!std::is_same<bool,typename std::remove_cv<T>::type>::value)
+ if(!std::is_same_v<bool,typename std::remove_cv<T>::type>)
{
INVOKE_BOOST_TEST( is_strictly_between_extrema<T>(1), file, line);
}
diff --git a/tn_range_type_trammels.hpp b/tn_range_type_trammels.hpp
index 76dd1a0..2b301a4 100644
--- a/tn_range_type_trammels.hpp
+++ b/tn_range_type_trammels.hpp
@@ -109,7 +109,7 @@ template<typename T>
class date_trammel
:public trammel_base<T>
{
- static_assert(std::is_same<calendar_date,T>::value);
+ static_assert(std::is_same_v<calendar_date,T>);
T nominal_minimum() const override {return gregorian_epoch();}
T default_value() const override {return today ();}
diff --git a/value_cast.hpp b/value_cast.hpp
index 5a6927a..39f291b 100644
--- a/value_cast.hpp
+++ b/value_cast.hpp
@@ -121,10 +121,13 @@ template<typename T>
struct is_string
{
// Here, is_convertible means 'T' is convertible to std::string.
- enum {value = std::is_convertible<T,std::string>::value};
+ enum {value = std::is_convertible_v<T,std::string>};
};
template<typename T>
+inline constexpr bool is_string_v = is_string<T>::value;
+
+template<typename T>
void throw_if_null_pointer(T)
{
}
@@ -162,23 +165,23 @@ struct value_cast_choice
{
// Here, is_convertible means 'From' is convertible to 'To'.
felicitously_convertible =
- std::is_convertible<From,To>::value
- &&!(std::is_array <From>::value && std::is_same<bool,To>::value)
- &&!(std::is_pointer <From>::value && std::is_same<bool,To>::value)
+ std::is_convertible_v<From,To>
+ &&!(std::is_array_v <From> && std::is_same_v<bool,To>)
+ &&!(std::is_pointer_v<From> && std::is_same_v<bool,To>)
};
enum
{
both_numeric =
- std::is_arithmetic<From>::value
- && std::is_arithmetic<To >::value
+ std::is_arithmetic_v<From>
+ && std::is_arithmetic_v<To >
};
enum
{
one_numeric_one_string =
- std::is_arithmetic<From>::value && is_string<To >::value
- || std::is_arithmetic<To >::value && is_string<From>::value
+ std::is_arithmetic_v<From> && is_string_v<To >
+ || std::is_arithmetic_v<To > && is_string_v<From>
};
enum
@@ -229,7 +232,7 @@ struct value_cast_chooser<To,From,e_stream>
template<typename To, typename From>
To value_cast(From const& from)
{
- static_assert(!std::is_pointer<To>::value);
+ static_assert(!std::is_pointer_v<To>);
return value_cast_chooser<To,From>()(from);
}
diff --git a/value_cast_test.cpp b/value_cast_test.cpp
index 961b3b6..a158d79 100644
--- a/value_cast_test.cpp
+++ b/value_cast_test.cpp
@@ -59,20 +59,20 @@ int test_main(int, char*[])
// These could be static assertions, but any failure would prevent
// other tests from running.
- BOOST_TEST( is_string<char *>::value);
- BOOST_TEST( is_string<char const *>::value);
- BOOST_TEST(!is_string<char volatile*>::value);
- BOOST_TEST(!is_string<char const volatile*>::value);
-
- BOOST_TEST( is_string<std::string >::value);
- BOOST_TEST( is_string<std::string const >::value);
- BOOST_TEST(!is_string<std::string volatile >::value);
- BOOST_TEST(!is_string<std::string const volatile >::value);
-
- BOOST_TEST( is_string<std::string &>::value);
- BOOST_TEST( is_string<std::string const &>::value);
- BOOST_TEST(!is_string<std::string volatile&>::value);
- BOOST_TEST(!is_string<std::string const volatile&>::value);
+ BOOST_TEST( is_string_v<char *>);
+ BOOST_TEST( is_string_v<char const *>);
+ BOOST_TEST(!is_string_v<char volatile*>);
+ BOOST_TEST(!is_string_v<char const volatile*>);
+
+ BOOST_TEST( is_string_v<std::string >);
+ BOOST_TEST( is_string_v<std::string const >);
+ BOOST_TEST(!is_string_v<std::string volatile >);
+ BOOST_TEST(!is_string_v<std::string const volatile >);
+
+ BOOST_TEST( is_string_v<std::string &>);
+ BOOST_TEST( is_string_v<std::string const &>);
+ BOOST_TEST(!is_string_v<std::string volatile&>);
+ BOOST_TEST(!is_string_v<std::string const volatile&>);
char const* ccp = "2.71828";
char* cp = const_cast<char*>("3.14159");
diff --git a/view_ex.tpp b/view_ex.tpp
index 59b145a..19cdf8d 100644
--- a/view_ex.tpp
+++ b/view_ex.tpp
@@ -49,7 +49,7 @@
template<typename ViewType>
std::string ViewName()
{
- static_assert(std::is_base_of<wxView,ViewType>::value);
+ static_assert(std::is_base_of_v<wxView,ViewType>);
return lmi::TypeInfo(typeid(ViewType)).Name();
}
diff --git a/wx_utility.hpp b/wx_utility.hpp
index b669ec2..b7870d0 100644
--- a/wx_utility.hpp
+++ b/wx_utility.hpp
@@ -95,10 +95,10 @@ void Connect
,wxEvtHandler* event_sink = nullptr
)
{
- static_assert(std::is_same<void,Return>::value);
- static_assert(std::is_base_of<wxEvtHandler,Class>::value);
+ static_assert(std::is_same_v<void,Return>);
+ static_assert(std::is_base_of_v<wxEvtHandler,Class>);
typedef typename std::remove_reference<Argument>::type argument_type;
- static_assert(std::is_base_of<wxEvent,argument_type>::value);
+ static_assert(std::is_base_of_v<wxEvent,argument_type>);
if(!object)
{
diff --git a/xml_serializable.tpp b/xml_serializable.tpp
index 7eba420..c71060b 100644
--- a/xml_serializable.tpp
+++ b/xml_serializable.tpp
@@ -43,8 +43,8 @@ xml_serializable<T>::~xml_serializable()
// Assert that static_cast<T cv&> doesn't engender undefined
// behavior, and that class T provides the expected operator[]()
// and member_names() functions.
- static_assert(std::is_base_of<xml_serializable <T>,T>::value);
- static_assert(std::is_base_of<MemberSymbolTable<T>,T>::value);
+ static_assert(std::is_base_of_v<xml_serializable <T>,T>);
+ static_assert(std::is_base_of_v<MemberSymbolTable<T>,T>);
}
template<typename T>
@@ -187,7 +187,7 @@ void xml_serializable<T>::immit_members_into(xml::element&
root) const
template<typename X, typename Y>
inline Y sfinae_cast
(X const& x
- ,typename std::enable_if<std::is_same<X,Y>::value>::type* = nullptr
+ ,typename std::enable_if<std::is_same_v<X,Y>>::type* = nullptr
)
{
return x;
@@ -196,7 +196,7 @@ inline Y sfinae_cast
template<typename X, typename Y>
inline Y sfinae_cast
(X const&
- ,typename std::enable_if<!std::is_same<X,Y>::value>::type* = nullptr
+ ,typename std::enable_if<!std::is_same_v<X,Y>>::type* = nullptr
)
{
alarum() << "Impermissible type conversion." << LMI_FLUSH;
diff --git a/xml_serialize.hpp b/xml_serialize.hpp
index 7b1e36e..16ad31e 100644
--- a/xml_serialize.hpp
+++ b/xml_serialize.hpp
@@ -60,7 +60,7 @@ namespace xml_serialize
template<typename T>
struct xml_io
{
- static_assert(!std::is_enum<T>::value); // Prefer mc_enum.
+ static_assert(!std::is_enum_v<T>); // Prefer mc_enum.
static void to_xml(xml::element& e, T const& t)
{
@@ -81,7 +81,7 @@ struct xml_pair_io
using T1 = typename P::first_type;
using T2 = typename P::second_type;
- static_assert(std::is_same<P,std::pair<T1,T2>>::value);
+ static_assert(std::is_same_v<P,std::pair<T1,T2>>);
static void to_xml(xml::element& parent, P const& p)
{
@@ -132,7 +132,7 @@ struct xml_sequence_io
{
using T = typename C::value_type;
- static_assert(std::is_same<C,std::vector<T>>::value);
+ static_assert(std::is_same_v<C,std::vector<T>>);
static void to_xml(xml::element& parent, C const& c)
{
@@ -190,8 +190,8 @@ struct xml_pair_container_io
using V = std::pair<K,T>;
static_assert
- ( std::is_same<C,std::map<K,T>>::value
- || std::is_same<C,std::unordered_map<K,T>>::value
+ ( std::is_same_v<C,std::map<K,T>>
+ || std::is_same_v<C,std::unordered_map<K,T>>
);
static void to_xml(xml::element& parent, C const& c)
- [lmi-commits] [lmi] master 75399fe 01/12: Improve documentation, (continued)
- [lmi-commits] [lmi] master 75399fe 01/12: Improve documentation, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master be4c0fd 05/12: Rename 'mete_*' functions for concinnity, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master d71f9e8 02/12: Improve parameter names, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master 9671a72 03/12: Rearrange for concinnity, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master 195d544 07/12: Improve explanation of certain unit tests, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master fdb2a62 04/12: Clarify unit-test output, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master 75cf29b 08/12: Rename local variables, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master fb65723 09/12: Serialize pairs to and from xml, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master d385546 10/12: Serialize associative-pair containers to and from xml, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master 2ba9033 11/12: Improve a variable's name, Greg Chicares, 2020/10/24
- [lmi-commits] [lmi] master 4427d76 12/12: C++17-ize,
Greg Chicares <=