mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-29 16:53:30 +01:00
Replace C++11 use of ::type with the _t suffix for std traits
This commit is contained in:
parent
ea6db67063
commit
66fe591477
@ -32,7 +32,7 @@ namespace Detail {
|
||||
|
||||
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 approx( static_cast<double>(value) );
|
||||
approx.m_epsilon = m_epsilon;
|
||||
@ -41,67 +41,67 @@ namespace Detail {
|
||||
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))
|
||||
{}
|
||||
|
||||
|
||||
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 ) {
|
||||
auto lhs_v = static_cast<double>(lhs);
|
||||
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 ) {
|
||||
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 ) {
|
||||
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 ) {
|
||||
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 ) {
|
||||
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 ) {
|
||||
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 ) {
|
||||
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 ) {
|
||||
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 ) {
|
||||
double epsilonAsDouble = static_cast<double>(newEpsilon);
|
||||
setEpsilon(epsilonAsDouble);
|
||||
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 ) {
|
||||
double marginAsDouble = static_cast<double>(newMargin);
|
||||
setMargin(marginAsDouble);
|
||||
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 ) {
|
||||
m_scale = static_cast<double>(newScale);
|
||||
return *this;
|
||||
|
@ -149,7 +149,7 @@ namespace Generators {
|
||||
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
|
@ -64,8 +64,8 @@ public:
|
||||
// TODO: Ideally this would be also constrained against the various char types,
|
||||
// but I don't expect users to run into that in practice.
|
||||
template <typename T>
|
||||
typename std::enable_if<std::is_integral<T>::value && !std::is_same<T, bool>::value,
|
||||
GeneratorWrapper<T>>::type
|
||||
std::enable_if_t<std::is_integral<T>::value && !std::is_same<T, bool>::value,
|
||||
GeneratorWrapper<T>>
|
||||
random(T a, T b) {
|
||||
return GeneratorWrapper<T>(
|
||||
std::make_unique<RandomIntegerGenerator<T>>(a, b)
|
||||
@ -73,8 +73,8 @@ random(T a, T b) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<std::is_floating_point<T>::value,
|
||||
GeneratorWrapper<T>>::type
|
||||
std::enable_if_t<std::is_floating_point<T>::value,
|
||||
GeneratorWrapper<T>>
|
||||
random(T a, T b) {
|
||||
return GeneratorWrapper<T>(
|
||||
std::make_unique<RandomFloatingGenerator<T>>(a, b)
|
||||
|
@ -107,17 +107,17 @@ namespace Matchers {
|
||||
std::string describe() const override {
|
||||
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 ) {
|
||||
approx.epsilon(newEpsilon);
|
||||
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 ) {
|
||||
approx.margin(newMargin);
|
||||
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 ) {
|
||||
approx.scale(newScale);
|
||||
return *this;
|
||||
|
@ -38,7 +38,7 @@ namespace Catch {
|
||||
using FunctionReturnType = std::remove_reference_t<std::remove_cv_t<std::invoke_result_t<Func, U>>>;
|
||||
#else
|
||||
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
|
||||
|
||||
} // namespace Catch
|
||||
|
@ -59,23 +59,23 @@ namespace Catch {
|
||||
std::string convertUnknownEnumToString( E e );
|
||||
|
||||
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::string>::type convertUnstreamable( T const& ) {
|
||||
std::string> convertUnstreamable( T const& ) {
|
||||
return Detail::unprintableString;
|
||||
}
|
||||
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::string>::type convertUnstreamable(T const& ex) {
|
||||
std::string> convertUnstreamable(T const& ex) {
|
||||
return ex.what();
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
typename std::enable_if<
|
||||
std::is_enum<T>::value
|
||||
, std::string>::type convertUnstreamable( T const& value ) {
|
||||
std::enable_if_t<
|
||||
std::is_enum<T>::value,
|
||||
std::string> convertUnstreamable( T const& value ) {
|
||||
return convertUnknownEnumToString( value );
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ namespace Catch {
|
||||
struct StringMaker {
|
||||
template <typename Fake = T>
|
||||
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) {
|
||||
ReusableStringStream rss;
|
||||
// NB: call using the function-like syntax to avoid ambiguity with
|
||||
@ -110,7 +110,7 @@ namespace Catch {
|
||||
|
||||
template <typename Fake = T>
|
||||
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 ) {
|
||||
#if !defined(CATCH_CONFIG_FALLBACK_STRINGIFIER)
|
||||
return Detail::convertUnstreamable(value);
|
||||
@ -126,12 +126,12 @@ namespace Catch {
|
||||
// Should be preferably called fully qualified, like ::Catch::Detail::stringify
|
||||
template <typename T>
|
||||
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>
|
||||
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)
|
||||
@ -515,7 +515,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
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 ) {
|
||||
return rangeToString( range );
|
||||
}
|
||||
|
@ -53,26 +53,26 @@ namespace {
|
||||
}
|
||||
|
||||
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) {
|
||||
return !!(static_cast<std::underlying_type<XmlFormatting>::type>(fmt & XmlFormatting::Indent));
|
||||
return !!(static_cast<std::underlying_type_t<XmlFormatting>>(fmt & XmlFormatting::Indent));
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
XmlFormatting operator | (XmlFormatting lhs, XmlFormatting rhs) {
|
||||
return static_cast<XmlFormatting>(
|
||||
static_cast<std::underlying_type<XmlFormatting>::type>(lhs) |
|
||||
static_cast<std::underlying_type<XmlFormatting>::type>(rhs)
|
||||
static_cast<std::underlying_type_t<XmlFormatting>>(lhs) |
|
||||
static_cast<std::underlying_type_t<XmlFormatting>>(rhs)
|
||||
);
|
||||
}
|
||||
|
||||
XmlFormatting operator & (XmlFormatting lhs, XmlFormatting rhs) {
|
||||
return static_cast<XmlFormatting>(
|
||||
static_cast<std::underlying_type<XmlFormatting>::type>(lhs) &
|
||||
static_cast<std::underlying_type<XmlFormatting>::type>(rhs)
|
||||
static_cast<std::underlying_type_t<XmlFormatting>>(lhs) &
|
||||
static_cast<std::underlying_type_t<XmlFormatting>>(rhs)
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user