mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-23 03:43:28 +01:00
Prefer _t over ::type form for std type traits
This commit is contained in:
parent
88c27ffaf2
commit
edad4d0af7
@ -93,8 +93,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
// sets lambda to be used in fun *and* executes benchmark!
|
||||
template <typename Fun,
|
||||
typename std::enable_if<!Detail::is_related<Fun, Benchmark>::value, int>::type = 0>
|
||||
template <typename Fun, std::enable_if_t<!Detail::is_related<Fun, Benchmark>::value, int> = 0>
|
||||
Benchmark & operator=(Fun func) {
|
||||
fun = Detail::BenchmarkFunction(func);
|
||||
run();
|
||||
|
@ -20,7 +20,7 @@ namespace Catch {
|
||||
template <typename T, bool Destruct>
|
||||
struct ObjectStorage
|
||||
{
|
||||
using TStorage = typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type;
|
||||
using TStorage = std::aligned_storage_t<sizeof(T), std::alignment_of<T>::value>;
|
||||
|
||||
ObjectStorage() : data() {}
|
||||
|
||||
@ -43,7 +43,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
template <bool AllowManualDestruction = !Destruct>
|
||||
typename std::enable_if<AllowManualDestruction>::type destruct()
|
||||
std::enable_if_t<AllowManualDestruction> destruct()
|
||||
{
|
||||
stored_object().~T();
|
||||
}
|
||||
@ -51,10 +51,10 @@ namespace Catch {
|
||||
private:
|
||||
// If this is a constructor benchmark, destruct the underlying object
|
||||
template <typename U>
|
||||
void destruct_on_exit(typename std::enable_if<Destruct, U>::type* = 0) { destruct<true>(); }
|
||||
void destruct_on_exit(std::enable_if_t<Destruct, U>* = 0) { destruct<true>(); }
|
||||
// Otherwise, don't
|
||||
template <typename U>
|
||||
void destruct_on_exit(typename std::enable_if<!Destruct, U>::type* = 0) { }
|
||||
void destruct_on_exit(std::enable_if_t<!Destruct, U>* = 0) { }
|
||||
|
||||
T& stored_object() {
|
||||
return *static_cast<T*>(static_cast<void*>(&data));
|
||||
|
@ -57,12 +57,12 @@ namespace Catch {
|
||||
}
|
||||
|
||||
template <typename Fn, typename... Args>
|
||||
inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> typename std::enable_if<!std::is_same<void, decltype(fn(args...))>::value>::type {
|
||||
inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> std::enable_if_t<!std::is_same<void, decltype(fn(args...))>::value> {
|
||||
deoptimize_value(CATCH_FORWARD(fn) (CATCH_FORWARD(args)...));
|
||||
}
|
||||
|
||||
template <typename Fn, typename... Args>
|
||||
inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> typename std::enable_if<std::is_same<void, decltype(fn(args...))>::value>::type {
|
||||
inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> std::enable_if_t<std::is_same<void, decltype(fn(args...))>::value> {
|
||||
CATCH_FORWARD(fn) (CATCH_FORWARD(args)...);
|
||||
}
|
||||
} // namespace Benchmark
|
||||
|
@ -22,11 +22,9 @@
|
||||
namespace Catch {
|
||||
namespace Benchmark {
|
||||
namespace Detail {
|
||||
template <typename T>
|
||||
using Decay = typename std::decay<T>::type;
|
||||
template <typename T, typename U>
|
||||
struct is_related
|
||||
: std::is_same<Decay<T>, Decay<U>> {};
|
||||
: std::is_same<std::decay_t<T>, std::decay_t<U>> {};
|
||||
|
||||
/// We need to reinvent std::function because every piece of code that might add overhead
|
||||
/// in a measurement context needs to have consistent performance characteristics so that we
|
||||
@ -76,9 +74,9 @@ namespace Catch {
|
||||
: f(new model<do_nothing>{ {} }) {}
|
||||
|
||||
template <typename Fun,
|
||||
typename std::enable_if<!is_related<Fun, BenchmarkFunction>::value, int>::type = 0>
|
||||
std::enable_if_t<!is_related<Fun, BenchmarkFunction>::value, int> = 0>
|
||||
BenchmarkFunction(Fun&& fun)
|
||||
: f(new model<typename std::decay<Fun>::type>(CATCH_FORWARD(fun))) {}
|
||||
: f(new model<std::decay_t<Fun>>(CATCH_FORWARD(fun))) {}
|
||||
|
||||
BenchmarkFunction( BenchmarkFunction&& that ) noexcept:
|
||||
f( CATCH_MOVE( that.f ) ) {}
|
||||
|
@ -26,7 +26,7 @@ namespace Catch {
|
||||
Fun fun;
|
||||
};
|
||||
template <typename Fun>
|
||||
repeater<typename std::decay<Fun>::type> repeat(Fun&& fun) {
|
||||
repeater<std::decay_t<Fun>> repeat(Fun&& fun) {
|
||||
return { CATCH_FORWARD(fun) };
|
||||
}
|
||||
} // namespace Detail
|
||||
|
@ -36,7 +36,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
template <typename Clock, typename Fun>
|
||||
using run_for_at_least_argument_t = typename std::conditional<is_callable<Fun(Chronometer)>::value, Chronometer, int>::type;
|
||||
using run_for_at_least_argument_t = std::conditional_t<is_callable<Fun(Chronometer)>::value, Chronometer, int>;
|
||||
|
||||
|
||||
[[noreturn]]
|
||||
|
@ -69,8 +69,7 @@ namespace Catch {
|
||||
template <typename ClassT, typename ReturnT, typename ArgT>
|
||||
struct UnaryLambdaTraits<ReturnT ( ClassT::* )( ArgT ) const> {
|
||||
static const bool isValid = true;
|
||||
using ArgType = typename std::remove_const<
|
||||
typename std::remove_reference<ArgT>::type>::type;
|
||||
using ArgType = std::remove_const_t<std::remove_reference_t<ArgT>>;
|
||||
using ReturnType = ReturnT;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user