Replace C++11 use of ::type with the _t suffix for std traits

This commit is contained in:
Martin Hořeňovský 2020-02-02 11:03:48 +01:00
parent ea6db67063
commit 66fe591477
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
7 changed files with 40 additions and 40 deletions

View File

@ -32,7 +32,7 @@ namespace Detail {
Approx operator-() const; Approx operator-() const;
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
Approx operator()( T const& value ) { Approx operator()( T const& value ) {
Approx approx( static_cast<double>(value) ); Approx approx( static_cast<double>(value) );
approx.m_epsilon = m_epsilon; approx.m_epsilon = m_epsilon;
@ -41,67 +41,67 @@ namespace Detail {
return approx; return approx;
} }
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
explicit Approx( T const& value ): Approx(static_cast<double>(value)) explicit Approx( T const& value ): Approx(static_cast<double>(value))
{} {}
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
friend bool operator == ( const T& lhs, Approx const& rhs ) { friend bool operator == ( const T& lhs, Approx const& rhs ) {
auto lhs_v = static_cast<double>(lhs); auto lhs_v = static_cast<double>(lhs);
return rhs.equalityComparisonImpl(lhs_v); return rhs.equalityComparisonImpl(lhs_v);
} }
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
friend bool operator == ( Approx const& lhs, const T& rhs ) { friend bool operator == ( Approx const& lhs, const T& rhs ) {
return operator==( rhs, lhs ); return operator==( rhs, lhs );
} }
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
friend bool operator != ( T const& lhs, Approx const& rhs ) { friend bool operator != ( T const& lhs, Approx const& rhs ) {
return !operator==( lhs, rhs ); return !operator==( lhs, rhs );
} }
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
friend bool operator != ( Approx const& lhs, T const& rhs ) { friend bool operator != ( Approx const& lhs, T const& rhs ) {
return !operator==( rhs, lhs ); return !operator==( rhs, lhs );
} }
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
friend bool operator <= ( T const& lhs, Approx const& rhs ) { friend bool operator <= ( T const& lhs, Approx const& rhs ) {
return static_cast<double>(lhs) < rhs.m_value || lhs == rhs; return static_cast<double>(lhs) < rhs.m_value || lhs == rhs;
} }
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
friend bool operator <= ( Approx const& lhs, T const& rhs ) { friend bool operator <= ( Approx const& lhs, T const& rhs ) {
return lhs.m_value < static_cast<double>(rhs) || lhs == rhs; return lhs.m_value < static_cast<double>(rhs) || lhs == rhs;
} }
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
friend bool operator >= ( T const& lhs, Approx const& rhs ) { friend bool operator >= ( T const& lhs, Approx const& rhs ) {
return static_cast<double>(lhs) > rhs.m_value || lhs == rhs; return static_cast<double>(lhs) > rhs.m_value || lhs == rhs;
} }
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
friend bool operator >= ( Approx const& lhs, T const& rhs ) { friend bool operator >= ( Approx const& lhs, T const& rhs ) {
return lhs.m_value > static_cast<double>(rhs) || lhs == rhs; return lhs.m_value > static_cast<double>(rhs) || lhs == rhs;
} }
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
Approx& epsilon( T const& newEpsilon ) { Approx& epsilon( T const& newEpsilon ) {
double epsilonAsDouble = static_cast<double>(newEpsilon); double epsilonAsDouble = static_cast<double>(newEpsilon);
setEpsilon(epsilonAsDouble); setEpsilon(epsilonAsDouble);
return *this; return *this;
} }
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
Approx& margin( T const& newMargin ) { Approx& margin( T const& newMargin ) {
double marginAsDouble = static_cast<double>(newMargin); double marginAsDouble = static_cast<double>(newMargin);
setMargin(marginAsDouble); setMargin(marginAsDouble);
return *this; return *this;
} }
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> template <typename T, typename = std::enable_if_t<std::is_constructible<double, T>::value>>
Approx& scale( T const& newScale ) { Approx& scale( T const& newScale ) {
m_scale = static_cast<double>(newScale); m_scale = static_cast<double>(newScale);
return *this; return *this;

View File

@ -149,7 +149,7 @@ namespace Generators {
template<typename... Ts> template<typename... Ts>
GeneratorWrapper<std::tuple<Ts...>> table( std::initializer_list<std::tuple<typename std::decay<Ts>::type...>> tuples ) { GeneratorWrapper<std::tuple<Ts...>> table( std::initializer_list<std::tuple<std::decay_t<Ts>...>> tuples ) {
return values<std::tuple<Ts...>>( tuples ); return values<std::tuple<Ts...>>( tuples );
} }

View File

@ -64,8 +64,8 @@ public:
// TODO: Ideally this would be also constrained against the various char types, // TODO: Ideally this would be also constrained against the various char types,
// but I don't expect users to run into that in practice. // but I don't expect users to run into that in practice.
template <typename T> template <typename T>
typename std::enable_if<std::is_integral<T>::value && !std::is_same<T, bool>::value, std::enable_if_t<std::is_integral<T>::value && !std::is_same<T, bool>::value,
GeneratorWrapper<T>>::type GeneratorWrapper<T>>
random(T a, T b) { random(T a, T b) {
return GeneratorWrapper<T>( return GeneratorWrapper<T>(
std::make_unique<RandomIntegerGenerator<T>>(a, b) std::make_unique<RandomIntegerGenerator<T>>(a, b)
@ -73,8 +73,8 @@ random(T a, T b) {
} }
template <typename T> template <typename T>
typename std::enable_if<std::is_floating_point<T>::value, std::enable_if_t<std::is_floating_point<T>::value,
GeneratorWrapper<T>>::type GeneratorWrapper<T>>
random(T a, T b) { random(T a, T b) {
return GeneratorWrapper<T>( return GeneratorWrapper<T>(
std::make_unique<RandomFloatingGenerator<T>>(a, b) std::make_unique<RandomFloatingGenerator<T>>(a, b)

View File

@ -107,17 +107,17 @@ namespace Matchers {
std::string describe() const override { std::string describe() const override {
return "is approx: " + ::Catch::Detail::stringify( m_comparator ); return "is approx: " + ::Catch::Detail::stringify( m_comparator );
} }
template <typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> template <typename = std::enable_if_t<std::is_constructible<double, T>::value>>
ApproxMatcher& epsilon( T const& newEpsilon ) { ApproxMatcher& epsilon( T const& newEpsilon ) {
approx.epsilon(newEpsilon); approx.epsilon(newEpsilon);
return *this; return *this;
} }
template <typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> template <typename = std::enable_if_t<std::is_constructible<double, T>::value>>
ApproxMatcher& margin( T const& newMargin ) { ApproxMatcher& margin( T const& newMargin ) {
approx.margin(newMargin); approx.margin(newMargin);
return *this; return *this;
} }
template <typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> template <typename = std::enable_if_t<std::is_constructible<double, T>::value>>
ApproxMatcher& scale( T const& newScale ) { ApproxMatcher& scale( T const& newScale ) {
approx.scale(newScale); approx.scale(newScale);
return *this; return *this;

View File

@ -38,7 +38,7 @@ namespace Catch {
using FunctionReturnType = std::remove_reference_t<std::remove_cv_t<std::invoke_result_t<Func, U>>>; using FunctionReturnType = std::remove_reference_t<std::remove_cv_t<std::invoke_result_t<Func, U>>>;
#else #else
template <typename Func, typename U> template <typename Func, typename U>
using FunctionReturnType = typename std::remove_reference<typename std::remove_cv<typename std::result_of<Func(U)>::type>::type>::type; using FunctionReturnType = std::remove_reference_t<std::remove_cv_t<std::result_of_t<Func(U)>>>;
#endif #endif
} // namespace Catch } // namespace Catch

View File

@ -59,23 +59,23 @@ namespace Catch {
std::string convertUnknownEnumToString( E e ); std::string convertUnknownEnumToString( E e );
template<typename T> template<typename T>
typename std::enable_if< std::enable_if_t<
!std::is_enum<T>::value && !std::is_base_of<std::exception, T>::value, !std::is_enum<T>::value && !std::is_base_of<std::exception, T>::value,
std::string>::type convertUnstreamable( T const& ) { std::string> convertUnstreamable( T const& ) {
return Detail::unprintableString; return Detail::unprintableString;
} }
template<typename T> template<typename T>
typename std::enable_if< std::enable_if_t<
!std::is_enum<T>::value && std::is_base_of<std::exception, T>::value, !std::is_enum<T>::value && std::is_base_of<std::exception, T>::value,
std::string>::type convertUnstreamable(T const& ex) { std::string> convertUnstreamable(T const& ex) {
return ex.what(); return ex.what();
} }
template<typename T> template<typename T>
typename std::enable_if< std::enable_if_t<
std::is_enum<T>::value std::is_enum<T>::value,
, std::string>::type convertUnstreamable( T const& value ) { std::string> convertUnstreamable( T const& value ) {
return convertUnknownEnumToString( value ); return convertUnknownEnumToString( value );
} }
@ -99,7 +99,7 @@ namespace Catch {
struct StringMaker { struct StringMaker {
template <typename Fake = T> template <typename Fake = T>
static static
typename std::enable_if<::Catch::Detail::IsStreamInsertable<Fake>::value, std::string>::type std::enable_if_t<::Catch::Detail::IsStreamInsertable<Fake>::value, std::string>
convert(const Fake& value) { convert(const Fake& value) {
ReusableStringStream rss; ReusableStringStream rss;
// NB: call using the function-like syntax to avoid ambiguity with // NB: call using the function-like syntax to avoid ambiguity with
@ -110,7 +110,7 @@ namespace Catch {
template <typename Fake = T> template <typename Fake = T>
static static
typename std::enable_if<!::Catch::Detail::IsStreamInsertable<Fake>::value, std::string>::type std::enable_if_t<!::Catch::Detail::IsStreamInsertable<Fake>::value, std::string>
convert( const Fake& value ) { convert( const Fake& value ) {
#if !defined(CATCH_CONFIG_FALLBACK_STRINGIFIER) #if !defined(CATCH_CONFIG_FALLBACK_STRINGIFIER)
return Detail::convertUnstreamable(value); return Detail::convertUnstreamable(value);
@ -126,12 +126,12 @@ namespace Catch {
// Should be preferably called fully qualified, like ::Catch::Detail::stringify // Should be preferably called fully qualified, like ::Catch::Detail::stringify
template <typename T> template <typename T>
std::string stringify(const T& e) { std::string stringify(const T& e) {
return ::Catch::StringMaker<typename std::remove_cv<typename std::remove_reference<T>::type>::type>::convert(e); return ::Catch::StringMaker<std::remove_cv_t<std::remove_reference_t<T>>>::convert(e);
} }
template<typename E> template<typename E>
std::string convertUnknownEnumToString( E e ) { std::string convertUnknownEnumToString( E e ) {
return ::Catch::Detail::stringify(static_cast<typename std::underlying_type<E>::type>(e)); return ::Catch::Detail::stringify(static_cast<std::underlying_type_t<E>>(e));
} }
#if defined(_MANAGED) #if defined(_MANAGED)
@ -515,7 +515,7 @@ namespace Catch {
} }
template<typename R> template<typename R>
struct StringMaker<R, typename std::enable_if<is_range<R>::value && !::Catch::Detail::IsStreamInsertable<R>::value>::type> { struct StringMaker<R, std::enable_if_t<is_range<R>::value && !::Catch::Detail::IsStreamInsertable<R>::value>> {
static std::string convert( R const& range ) { static std::string convert( R const& range ) {
return rangeToString( range ); return rangeToString( range );
} }

View File

@ -53,26 +53,26 @@ namespace {
} }
bool shouldNewline(XmlFormatting fmt) { bool shouldNewline(XmlFormatting fmt) {
return !!(static_cast<std::underlying_type<XmlFormatting>::type>(fmt & XmlFormatting::Newline)); return !!(static_cast<std::underlying_type_t<XmlFormatting>>(fmt & XmlFormatting::Newline));
} }
bool shouldIndent(XmlFormatting fmt) { bool shouldIndent(XmlFormatting fmt) {
return !!(static_cast<std::underlying_type<XmlFormatting>::type>(fmt & XmlFormatting::Indent)); return !!(static_cast<std::underlying_type_t<XmlFormatting>>(fmt & XmlFormatting::Indent));
} }
} // anonymous namespace } // anonymous namespace
XmlFormatting operator | (XmlFormatting lhs, XmlFormatting rhs) { XmlFormatting operator | (XmlFormatting lhs, XmlFormatting rhs) {
return static_cast<XmlFormatting>( return static_cast<XmlFormatting>(
static_cast<std::underlying_type<XmlFormatting>::type>(lhs) | static_cast<std::underlying_type_t<XmlFormatting>>(lhs) |
static_cast<std::underlying_type<XmlFormatting>::type>(rhs) static_cast<std::underlying_type_t<XmlFormatting>>(rhs)
); );
} }
XmlFormatting operator & (XmlFormatting lhs, XmlFormatting rhs) { XmlFormatting operator & (XmlFormatting lhs, XmlFormatting rhs) {
return static_cast<XmlFormatting>( return static_cast<XmlFormatting>(
static_cast<std::underlying_type<XmlFormatting>::type>(lhs) & static_cast<std::underlying_type_t<XmlFormatting>>(lhs) &
static_cast<std::underlying_type<XmlFormatting>::type>(rhs) static_cast<std::underlying_type_t<XmlFormatting>>(rhs)
); );
} }