66
77#include < cassert>
88#include < cstddef>
9+ #include < cstdlib>
910#include < bit>
1011#include < concepts>
12+ #include < exception>
1113#include < initializer_list>
1214#include < limits>
1315#include < memory>
1618#include < utility>
1719
1820#ifdef __cpp_rtti
19- #ifndef __cpp_exceptions
20- #include < cstdlib> // For std::abort() when "throw" is not available
21- #endif // __cpp_exceptions
2221#include < optional>
2322#include < typeinfo>
2423#endif // __cpp_rtti
3130#error "Proxy requires C++20 attribute no_unique_address"
3231#endif
3332
33+ #ifdef __cpp_exceptions
34+ #define ___PRO_THROW (...) throw __VA_ARGS__
35+ #else
36+ #define ___PRO_THROW (...) std::abort()
37+ #endif // __cpp_exceptions
38+
3439#ifdef _MSC_VER
3540#define ___PRO_ENFORCE_EBO __declspec (empty_bases)
3641#else
@@ -1256,7 +1261,11 @@ using proxy_view = proxy<observer_facade<F>>;
12561261 accessor () noexcept { ::std::ignore = &accessor::__VA_ARGS__; })
12571262
12581263#ifdef __cpp_rtti
1259- struct bad_proxy_cast : std::bad_cast {};
1264+ class bad_proxy_cast : public std ::bad_cast {
1265+ public:
1266+ bad_proxy_cast () noexcept = default ;
1267+ char const * what () const noexcept override { return " pro::bad_proxy_cast" ; }
1268+ };
12601269#endif // __cpp_rtti
12611270
12621271namespace details {
@@ -1554,12 +1563,6 @@ template <std::size_t N>
15541563sign (const char (&str)[N]) -> sign<N>;
15551564
15561565#ifdef __cpp_rtti
1557- #ifdef __cpp_exceptions
1558- #define ___PRO_THROW (...) throw __VA_ARGS__
1559- #else
1560- #define ___PRO_THROW (...) std::abort()
1561- #endif // __cpp_exceptions
1562-
15631566struct proxy_cast_context {
15641567 const std::type_info* type_ptr;
15651568 bool is_ref;
@@ -1657,9 +1660,21 @@ ___PRO_DEBUG(
16571660
16581661 const std::type_info* info;
16591662};
1660- #undef ___PRO_THROW
16611663#endif // __cpp_rtti
16621664
1665+ struct wildcard {
1666+ wildcard () = delete ;
1667+
1668+ template <class T >
1669+ [[noreturn]] operator T () {
1670+ #ifdef __cpp_lib_unreachable
1671+ std::unreachable ();
1672+ #else
1673+ std::abort ();
1674+ #endif // __cpp_lib_unreachable
1675+ }
1676+ };
1677+
16631678} // namespace details
16641679
16651680template <class Cs , class Rs , proxiable_ptr_constraints C>
@@ -1969,6 +1984,20 @@ struct explicit_conversion_dispatch : details::cast_dispatch_base<true, false> {
19691984};
19701985using conversion_dispatch = explicit_conversion_dispatch;
19711986
1987+ class not_implemented : public std ::exception {
1988+ public:
1989+ not_implemented () noexcept = default ;
1990+ char const * what () const noexcept override { return " pro::not_implemented" ; }
1991+ };
1992+
1993+ template <class D >
1994+ struct weak_dispatch : D {
1995+ using D::operator ();
1996+ template <class ... Args>
1997+ [[noreturn]] details::wildcard operator ()(std::nullptr_t , Args&&...)
1998+ { ___PRO_THROW (not_implemented{}); }
1999+ };
2000+
19722001#define ___PRO_EXPAND_IMPL (__X ) __X
19732002#define ___PRO_EXPAND_MACRO_IMPL ( \
19742003 __MACRO, __1, __2, __3, __NAME, ...) \
@@ -2049,7 +2078,8 @@ ___PRO_DEBUG( \
20492078 ___PRO_EXPAND_MACRO (___PRO_DEF_FREE_AS_MEM_DISPATCH, __NAME, __VA_ARGS__)
20502079
20512080#define PRO_DEF_WEAK_DISPATCH (__NAME, __D, __FUNC ) \
2052- struct __NAME : __D { \
2081+ struct [[deprecated(" 'PRO_DEF_WEAK_DISPATCH' is deprecated. " \
2082+ " Use pro::weak_dispatch<" #__D " > instead." )]] __NAME : __D { \
20532083 using __D::operator (); \
20542084 template <class ... __Args> \
20552085 decltype (auto ) operator ()(::std::nullptr_t , __Args&&... __args) \
@@ -2058,6 +2088,7 @@ ___PRO_DEBUG( \
20582088
20592089} // namespace pro
20602090
2091+ #undef ___PRO_THROW
20612092#undef ___PRO_NO_UNIQUE_ADDRESS_ATTRIBUTE
20622093
20632094#endif // _MSFT_PROXY_
0 commit comments