flatten 20260225
This commit is contained in:
26
tjp/core/sfinae/_tests/if_or.cpp
Executable file
26
tjp/core/sfinae/_tests/if_or.cpp
Executable file
@@ -0,0 +1,26 @@
|
||||
// License: Modified MIT (NON-AI)
|
||||
// See the LICENSE file in the root directory for license information.
|
||||
// Copyright 2025 Timothy Prepscius
|
||||
|
||||
#include <tjp/core/testing/catch.hpp>
|
||||
#include <tjp/core/sfinae/if_or.hpp>
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace tjp::core::sfinae {
|
||||
namespace {
|
||||
|
||||
SCENARIO("core::sfinae::if_or")
|
||||
{
|
||||
static_assert(
|
||||
std::is_same_v<if_or<true, int, float>::type, int>
|
||||
);
|
||||
|
||||
static_assert(
|
||||
std::is_same_v<if_or<false, int, float>::type, float>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
20
tjp/core/sfinae/if_or.hpp
Normal file
20
tjp/core/sfinae/if_or.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
// License: Modified MIT (NON-AI)
|
||||
// See the LICENSE file in the root directory for license information.
|
||||
// Copyright 2025 Timothy Prepscius
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace tjp {
|
||||
namespace core {
|
||||
namespace sfinae {
|
||||
|
||||
template<bool B, class T = void, class U = void>
|
||||
struct if_or { typedef U type; };
|
||||
|
||||
template<class T, class U>
|
||||
struct if_or <true, T, U> { typedef T type; };
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user