Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 0 additions & 74 deletions tests/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,80 +343,6 @@ bool check_equal_values(const sycl::marray<T, numElements>& lhs,
}
#endif

/** Enables concept checking ahead of the Concepts TS
* Idea for macro taken from Eric Niebler's range-v3
*/
#define REQUIRES_IMPL(B) typename std::enable_if<(B), int>::type = 1
#define REQUIRES(...) REQUIRES_IMPL((__VA_ARGS__))

/**
* @brief Transforms the input type into a dependant type and performs
* an enable_if based on the condition.
*
* Useful for disabling a member function based on a template parameter
* of the class.
* @param typeName Non-dependant type to be made dependant
* @param condition The condition specifying when the template
* should be enabled. typeName can occur within this expression.
*/
#define ENABLE_IF_DEPENDANT(typeName, condition) \
typename overloadDependantT = typeName, \
typename = typename std::enable_if < \
std::is_same<typeName, overloadDependantT>::value && \
(condition) > ::type

template <bool condition, typename F1, typename F2,
bool same_return_type =
std::is_same<typename std::result_of<F1&()>::type,
typename std::result_of<F2&()>::type>::value>
struct if_constexpr_impl;

template <bool condition, typename F1, typename F2>
struct if_constexpr_impl<condition, F1, F2, true> {
static constexpr auto result(const F1& f1, const F2& f2) -> decltype(f1()) {
return condition ? f1() : f2();
}
};

template <typename F1, typename F2>
struct if_constexpr_impl<true, F1, F2, false> {
static constexpr auto result(const F1& f1, const F2&) -> decltype(f1()) {
return f1();
}
};

template <typename F1, typename F2>
struct if_constexpr_impl<false, F1, F2, false> {
static constexpr auto result(const F1&, const F2& f2) -> decltype(f2()) {
return f2();
}
};

/**
* @brief Library implementation for C++17's compile-time if-statement so that
* it works in C++11. Generates a call to the invocable object `f1` if
* `condition == true` at compile-time, otherwise a call to `f2` is generated.
*/
template <bool condition, typename F1, typename F2,
typename R = typename std::conditional<
condition, typename std::result_of<F1&()>::type,
typename std::result_of<F2&()>::type>::type>
inline R if_constexpr(const F1& f1, const F2& f2) {
return if_constexpr_impl<condition, F1, F2>::result(f1, f2);
}

/**
* @brief Library implementation for C++17's compile-time if-statement so that
* it works in C++11. Generates a call to the invocable object `f` if
* `condition == true` at compile-time, otherwise no code is generated.
*/
template <bool condition, typename F>
inline void if_constexpr(const F& f) {
if (condition) {
f();
}
}

/**
* @brief Tag to denote mapping of integer coordinates to real scale
*
Expand Down