Skip to content

Commit ff3c418

Browse files
committed
🎨 Simply CX_WRAP for types
Problem: - `CX_WRAP` on types returns a callable that returns a `type_identity`. In fact, `type_identity` is an empty struct, so it's constexpr-usable. Solution: - Return a `type_identity<T>` from `CX_WRAP(T)`. Note: - `STDX_CT_FORMAT` tests are unaltered and still format type names at compile time.
1 parent 8d5072c commit ff3c418

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

include/stdx/utility.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,7 @@ constexpr auto cx_detect1(auto) { return 0; }
297297
STDX_PRAGMA(diagnostic push) \
298298
STDX_PRAGMA(diagnostic ignored "-Wold-style-cast") \
299299
if constexpr (STDX_IS_TYPE(__VA_ARGS__)) { \
300-
return ::stdx::overload{ \
301-
::stdx::cxv_detail::cx_base{}, [&] { \
302-
return ::stdx::type_identity<__typeof__(__VA_ARGS__)>{}; \
303-
}}; \
300+
return ::stdx::type_identity<__typeof__(__VA_ARGS__)>{}; \
304301
} else if constexpr (::stdx::is_cx_value_v< \
305302
std::invoke_result_t<decltype(f)>> or \
306303
std::is_empty_v< \

test/utility.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,16 +359,14 @@ TEST_CASE("CX_WRAP template argument", "[utility]") {
359359
}
360360

361361
TEST_CASE("CX_WRAP type argument", "[utility]") {
362-
STATIC_REQUIRE(stdx::is_cx_value_v<decltype(CX_WRAP(int))>);
363362
STATIC_REQUIRE(
364-
std::is_same_v<decltype(CX_WRAP(int)()), stdx::type_identity<int>>);
363+
std::is_same_v<decltype(CX_WRAP(int)), stdx::type_identity<int>>);
365364
}
366365

367366
TEST_CASE("CX_WRAP empty type argument", "[utility]") {
368367
using X = std::integral_constant<int, 17>;
369-
STATIC_REQUIRE(stdx::is_cx_value_v<decltype(CX_WRAP(X))>);
370368
STATIC_REQUIRE(
371-
std::is_same_v<decltype(CX_WRAP(X)()), stdx::type_identity<X>>);
369+
std::is_same_v<decltype(CX_WRAP(X)), stdx::type_identity<X>>);
372370
}
373371

374372
TEST_CASE("CX_WRAP integral_constant arg", "[utility]") {

0 commit comments

Comments
 (0)