Cleanup: use c++17 helper variable templates

This commit is contained in:
Jacques Lucke 2020-07-08 20:39:12 +02:00
parent e4926c167b
commit f7d5d4ee3b
5 changed files with 8 additions and 9 deletions

View File

@ -65,13 +65,13 @@ inline constexpr uint32_t power_of_2_max_u_constexpr(const uint32_t x)
template<typename IntT> inline constexpr IntT ceil_division(const IntT x, const IntT y)
{
BLI_STATIC_ASSERT(!std::is_signed<IntT>::value, "");
BLI_STATIC_ASSERT(!std::is_signed_v<IntT>, "");
return x / y + ((x % y) != 0);
}
template<typename IntT> inline constexpr IntT floor_division(const IntT x, const IntT y)
{
BLI_STATIC_ASSERT(!std::is_signed<IntT>::value, "");
BLI_STATIC_ASSERT(!std::is_signed_v<IntT>, "");
return x / y;
}

View File

@ -1050,7 +1050,7 @@ class Map {
{
using CreateReturnT = decltype(create_value(nullptr));
using ModifyReturnT = decltype(modify_value(nullptr));
BLI_STATIC_ASSERT((std::is_same<CreateReturnT, ModifyReturnT>::value),
BLI_STATIC_ASSERT((std::is_same_v<CreateReturnT, ModifyReturnT>),
"Both callbacks should return the same type.");
this->ensure_can_add();

View File

@ -49,7 +49,7 @@ template<typename T> void destruct_n(T *ptr, uint n)
/* This is not strictly necessary, because the loop below will be optimized away anyway. It is
* nice to make behavior this explicitly, though. */
if (std::is_trivially_destructible<T>::value) {
if (std::is_trivially_destructible_v<T>) {
return;
}
@ -73,7 +73,7 @@ template<typename T> void default_construct_n(T *ptr, uint n)
{
/* This is not strictly necessary, because the loop below will be optimized away anyway. It is
* nice to make behavior this explicitly, though. */
if (std::is_trivially_constructible<T>::value) {
if (std::is_trivially_constructible_v<T>) {
return;
}

View File

@ -128,8 +128,7 @@ template<typename T> class Span {
* Span<T *> -> Span<const T *>
* Span<Derived *> -> Span<Base *>
*/
template<typename U,
typename std::enable_if<std::is_convertible<U *, T>::value>::type * = nullptr>
template<typename U, typename std::enable_if_t<std::is_convertible_v<U *, T>> * = nullptr>
Span(Span<U *> array) : Span((T *)array.data(), array.size())
{
}

View File

@ -204,7 +204,7 @@ class CPPType {
* for optimization purposes.
*
* C++ equivalent:
* std::is_trivially_destructible<T>::value;
* std::is_trivially_destructible_v<T>;
*/
bool is_trivially_destructible() const
{
@ -721,7 +721,7 @@ static std::unique_ptr<const CPPType> create_cpp_type(StringRef name, const T &d
const CPPType *type = new CPPType(name,
sizeof(T),
alignof(T),
std::is_trivially_destructible<T>::value,
std::is_trivially_destructible_v<T>,
construct_default_cb<T>,
construct_default_n_cb<T>,
construct_default_indices_cb<T>,