@@ -151,9 +151,12 @@ struct type_val {
151151 friend constexpr auto operator +(T &&t, U &&) -> T {
152152 return t;
153153 }
154- friend constexpr auto operator +(type_val const &f) -> type_val;
154+ friend constexpr auto operator +(type_val const &f) -> type_val { return f; }
155155 // NOLINTNEXTLINE(google-explicit-constructor)
156- template <typename T> constexpr operator T () const ;
156+ template <typename T> constexpr operator T () const {
157+ extern auto cxv_type_val_get_t (T *) -> T;
158+ return cxv_type_val_get_t (nullptr );
159+ }
157160};
158161
159162template <int > constexpr auto is_type () -> std::false_type;
@@ -166,6 +169,14 @@ template <typename T> struct typer<from_any(T)> {
166169
167170template <int > constexpr auto type_of () -> void;
168171template <typename T> constexpr auto type_of () -> typename typer<T>::type;
172+
173+ class cx_base {
174+ struct unusable {};
175+
176+ public:
177+ using cx_value_t [[maybe_unused]] = void ;
178+ constexpr auto operator ()(unusable) const {}
179+ };
169180} // namespace cxv_detail
170181
171182template <typename T>
@@ -192,31 +203,24 @@ constexpr auto is_aligned_with = [](auto v) -> bool {
192203
193204#ifndef CX_VALUE
194205#define CX_VALUE (...) \
195- [] { \
206+ []() constexpr { \
196207 STDX_PRAGMA (diagnostic push) \
197208 STDX_PRAGMA (diagnostic ignored " -Wold-style-cast" ) \
198209 STDX_PRAGMA (diagnostic ignored " -Wunused-value" ) \
199210 if constexpr (decltype (stdx::cxv_detail::is_type< \
200211 stdx::cxv_detail::from_any ( \
201212 __VA_ARGS__)>())::value) { \
202- [[maybe_unused]] struct { \
203- constexpr auto operator ()() const noexcept { \
204- return stdx::type_identity< \
205- decltype (stdx::cxv_detail::type_of< \
206- stdx::cxv_detail::from_any ( \
207- __VA_ARGS__)>())>{}; \
208- } \
209- using cx_value_t [[maybe_unused]] = void ; \
210- } val; \
211- return val; \
213+ return stdx::overload{stdx::cxv_detail::cx_base{}, [] { \
214+ return stdx::type_identity< \
215+ decltype (stdx::cxv_detail::type_of< \
216+ stdx::cxv_detail::from_any ( \
217+ __VA_ARGS__)>())>{}; \
218+ }}; \
212219 } else { \
213- [[maybe_unused]] struct { \
214- constexpr auto operator ()() const { \
215- return (__VA_ARGS__) + stdx::cxv_detail::type_val{}; \
216- } \
217- using cx_value_t [[maybe_unused]] = void ; \
218- } val; \
219- return val; \
220+ return stdx::overload{stdx::cxv_detail::cx_base{}, [] { \
221+ return (__VA_ARGS__) + \
222+ stdx::cxv_detail::type_val{}; \
223+ }}; \
220224 } \
221225 STDX_PRAGMA (diagnostic pop) \
222226 }()
0 commit comments