191191 // in our -pure-cpp2 "import std;" simulation mode... if you need this,
192192 // use mixed mode (not -pure-cpp2) and #include all the headers you need
193193 // including this one
194- //
194+ //
195195 // #include <execution>
196196 #endif
197197
@@ -480,7 +480,7 @@ template<typename T>
480480auto Typeid () -> decltype(auto ) {
481481#ifdef CPP2_NO_RTTI
482482 Type.expects (
483- !" 'any' dynamic casting is disabled with -fno-rtti" , // more likely to appear on console
483+ !" 'any' dynamic casting is disabled with -fno-rtti" , // more likely to appear on console
484484 " 'any' dynamic casting is disabled with -fno-rtti" // make message available to hooked handlers
485485 );
486486#else
@@ -670,12 +670,19 @@ class out {
670670// -----------------------------------------------------------------------
671671//
672672#if defined(_MSC_VER) && !defined(__clang_major__)
673- #define CPP2_FORCE_INLINE __forceinline
674- #define CPP2_FORCE_INLINE_LAMBDA [[msvc::forceinline]]
673+ #define CPP2_FORCE_INLINE __forceinline
674+ #define CPP2_FORCE_INLINE_LAMBDA [[msvc::forceinline]]
675+ #define CPP2_FORCE_INLINE_LAMBDA_CLANG /* empty */
675676 #define CPP2_LAMBDA_NO_DISCARD
676677#else
677- #define CPP2_FORCE_INLINE __attribute__ ((always_inline))
678- #define CPP2_FORCE_INLINE_LAMBDA __attribute__ ((always_inline))
678+ #define CPP2_FORCE_INLINE __attribute__ ((always_inline))
679+ #if defined (__clang__)
680+ #define CPP2_FORCE_INLINE_LAMBDA /* empty */
681+ #define CPP2_FORCE_INLINE_LAMBDA_CLANG __attribute__ ((always_inline))
682+ #else
683+ #define CPP2_FORCE_INLINE_LAMBDA __attribute__ ((always_inline))
684+ #define CPP2_FORCE_INLINE_LAMBDA_CLANG /* empty */
685+ #endif
679686
680687 #if defined(__clang_major__)
681688 // Also check __cplusplus, only to satisfy Clang -pedantic-errors
@@ -701,84 +708,40 @@ class out {
701708#endif
702709
703710
704- // Note: [&] is because a nested UFCS might be viewed as trying to capture 'this'
705-
706- #define CPP2_UFCS (FUNCNAME,PARAM1,...) \
707- [&] CPP2_LAMBDA_NO_DISCARD (auto && obj, auto && ...params) CPP2_FORCE_INLINE_LAMBDA -> decltype (auto ) { \
708- if constexpr (requires { CPP2_FORWARD (obj).FUNCNAME (CPP2_FORWARD (params)...); }) { \
709- return CPP2_FORWARD (obj).FUNCNAME (CPP2_FORWARD (params)...); \
711+ #define CPP2_UFCS_ (LAMBDADEFCAPT,TEMPKW,...) \
712+ [LAMBDADEFCAPT] CPP2_LAMBDA_NO_DISCARD (auto && obj, auto && ...params) CPP2_FORCE_INLINE_LAMBDA_CLANG \
713+ noexcept (requires { requires requires { CPP2_FORWARD (obj).TEMPKW __VA_ARGS__ (CPP2_FORWARD (params)...); }; \
714+ requires noexcept (CPP2_FORWARD (obj).TEMPKW __VA_ARGS__ (CPP2_FORWARD (params)...)); } \
715+ || requires { requires !requires { CPP2_FORWARD (obj).TEMPKW __VA_ARGS__ (CPP2_FORWARD (params)...); }; \
716+ requires noexcept (__VA_ARGS__ (CPP2_FORWARD (obj), CPP2_FORWARD (params)...)); }) \
717+ CPP2_FORCE_INLINE_LAMBDA -> decltype (auto ) \
718+ requires requires { CPP2_FORWARD (obj).TEMPKW __VA_ARGS__ (CPP2_FORWARD (params)...); } \
719+ || requires { __VA_ARGS__ (CPP2_FORWARD (obj), CPP2_FORWARD (params)...); } { \
720+ if constexpr (requires { CPP2_FORWARD (obj).TEMPKW __VA_ARGS__ (CPP2_FORWARD (params)...); }) { \
721+ return CPP2_FORWARD (obj).TEMPKW __VA_ARGS__ (CPP2_FORWARD (params)...); \
710722 } else { \
711- return FUNCNAME (CPP2_FORWARD (obj), CPP2_FORWARD (params)...); \
723+ return __VA_ARGS__ (CPP2_FORWARD (obj), CPP2_FORWARD (params)...); \
712724 } \
713- }(PARAM1, __VA_ARGS__)
714-
715- #define CPP2_UFCS_0 (FUNCNAME,PARAM1 ) \
716- [&] CPP2_LAMBDA_NO_DISCARD (auto && obj) CPP2_FORCE_INLINE_LAMBDA -> decltype (auto ) { \
717- if constexpr (requires { CPP2_FORWARD (obj).FUNCNAME (); }) { \
718- return CPP2_FORWARD (obj).FUNCNAME (); \
719- } else { \
720- return FUNCNAME (CPP2_FORWARD (obj)); \
721- } \
722- }(PARAM1)
725+ }
723726
727+ #if 1 // When not rebasing, enable this branch.
728+ #define CPP2_UFCS (...) CPP2_UFCS_(&,,__VA_ARGS__)
729+ #define CPP2_UFCS_TEMPLATE (...) CPP2_UFCS_(&,template ,__VA_ARGS__)
730+ #define CPP2_UFCS_NONLOCAL (...) CPP2_UFCS_(,,__VA_ARGS__)
731+ #define CPP2_UFCS_TEMPLATE_NONLOCAL (...) CPP2_UFCS_(,template ,__VA_ARGS__)
732+ #else // When rebasing, enable this branch.
733+ // `git restore --staged` and `git restore` conflicting sources.
734+ // Compile `cppfront`. Regenerate conflicting sources. Disable this branch. Complete rebase.
724735#define CPP2_UFCS_REMPARENS(...) __VA_ARGS__
725-
726- #define CPP2_UFCS_TEMPLATE (FUNCNAME,TEMPARGS,PARAM1,...) \
727- [&] CPP2_LAMBDA_NO_DISCARD (auto && obj, auto && ...params) CPP2_FORCE_INLINE_LAMBDA -> decltype (auto ) { \
728- if constexpr (requires { CPP2_FORWARD (obj).template FUNCNAME CPP2_UFCS_REMPARENS TEMPARGS (CPP2_FORWARD (params)...); }) { \
729- return CPP2_FORWARD (obj).template FUNCNAME CPP2_UFCS_REMPARENS TEMPARGS (CPP2_FORWARD (params)...); \
730- } else { \
731- return FUNCNAME CPP2_UFCS_REMPARENS TEMPARGS (CPP2_FORWARD (obj), CPP2_FORWARD (params)...); \
732- } \
733- }(PARAM1, __VA_ARGS__)
734-
735- #define CPP2_UFCS_TEMPLATE_0 (FUNCNAME,TEMPARGS,PARAM1 ) \
736- [&] CPP2_LAMBDA_NO_DISCARD (auto && obj) CPP2_FORCE_INLINE_LAMBDA -> decltype (auto ) { \
737- if constexpr (requires { CPP2_FORWARD (obj).template FUNCNAME CPP2_UFCS_REMPARENS TEMPARGS (); }) { \
738- return CPP2_FORWARD (obj).template FUNCNAME CPP2_UFCS_REMPARENS TEMPARGS (); \
739- } else { \
740- return FUNCNAME CPP2_UFCS_REMPARENS TEMPARGS (CPP2_FORWARD (obj)); \
741- } \
742- }(PARAM1)
743-
744-
745- // But for non-local lambdas [&] is not allowed
746-
747- #define CPP2_UFCS_NONLOCAL (FUNCNAME,PARAM1,...) \
748- [] CPP2_LAMBDA_NO_DISCARD (auto && obj, auto && ...params) CPP2_FORCE_INLINE_LAMBDA -> decltype (auto ) { \
749- if constexpr (requires { CPP2_FORWARD (obj).FUNCNAME (CPP2_FORWARD (params)...); }) { \
750- return CPP2_FORWARD (obj).FUNCNAME (CPP2_FORWARD (params)...); \
751- } else { \
752- return FUNCNAME (CPP2_FORWARD (obj), CPP2_FORWARD (params)...); \
753- } \
754- }(PARAM1, __VA_ARGS__)
755-
756- #define CPP2_UFCS_0_NONLOCAL (FUNCNAME,PARAM1 ) \
757- [] CPP2_LAMBDA_NO_DISCARD (auto && obj) CPP2_FORCE_INLINE_LAMBDA -> decltype (auto ) { \
758- if constexpr (requires { CPP2_FORWARD (obj).FUNCNAME (); }) { \
759- return CPP2_FORWARD (obj).FUNCNAME (); \
760- } else { \
761- return FUNCNAME (CPP2_FORWARD (obj)); \
762- } \
763- }(PARAM1)
764-
765- #define CPP2_UFCS_TEMPLATE_NONLOCAL (FUNCNAME,TEMPARGS,PARAM1,...) \
766- [] CPP2_LAMBDA_NO_DISCARD (auto && obj, auto && ...params) CPP2_FORCE_INLINE_LAMBDA -> decltype (auto ) { \
767- if constexpr (requires { CPP2_FORWARD (obj).template FUNCNAME CPP2_UFCS_REMPARENS TEMPARGS (CPP2_FORWARD (params)...); }) { \
768- return CPP2_FORWARD (obj).template FUNCNAME CPP2_UFCS_REMPARENS TEMPARGS (CPP2_FORWARD (params)...); \
769- } else { \
770- return FUNCNAME CPP2_UFCS_REMPARENS TEMPARGS (CPP2_FORWARD (obj), CPP2_FORWARD (params)...); \
771- } \
772- }(PARAM1, __VA_ARGS__)
773-
774- #define CPP2_UFCS_TEMPLATE_0_NONLOCAL (FUNCNAME,TEMPARGS,PARAM1 ) \
775- [] CPP2_LAMBDA_NO_DISCARD (auto && obj) CPP2_FORCE_INLINE_LAMBDA -> decltype (auto ) { \
776- if constexpr (requires { CPP2_FORWARD (obj).template FUNCNAME CPP2_UFCS_REMPARENS TEMPARGS (); }) { \
777- return CPP2_FORWARD (obj).template FUNCNAME CPP2_UFCS_REMPARENS TEMPARGS (); \
778- } else { \
779- return FUNCNAME CPP2_UFCS_REMPARENS TEMPARGS (CPP2_FORWARD (obj)); \
780- } \
781- }(PARAM1)
736+ #define CPP2_UFCS(FUNCNAME,PARAM1,...) CPP2_UFCS_(&,,FUNCNAME)(PARAM1,__VA_ARGS__)
737+ #define CPP2_UFCS_0(FUNCNAME,PARAM1) CPP2_UFCS_(&,,FUNCNAME)(PARAM1)
738+ #define CPP2_UFCS_TEMPLATE(FUNCNAME,TEMPARGS,PARAM1,...) CPP2_UFCS_(&,template,FUNCNAME CPP2_UFCS_REMPARENS TEMPARGS)(PARAM1,__VA_ARGS__)
739+ #define CPP2_UFCS_TEMPLATE_0(FUNCNAME,TEMPARGS,PARAM1) CPP2_UFCS_(&,template,FUNCNAME CPP2_UFCS_REMPARENS TEMPARGS)(PARAM1)
740+ #define CPP2_UFCS_NONLOCAL(FUNCNAME,PARAM1,...) CPP2_UFCS_(,,FUNCNAME)(PARAM1,__VA_ARGS__)
741+ #define CPP2_UFCS_0_NONLOCAL(FUNCNAME,PARAM1) CPP2_UFCS_(,,FUNCNAME)(PARAM1)
742+ #define CPP2_UFCS_TEMPLATE_NONLOCAL(FUNCNAME,TEMPARGS,PARAM1,...) CPP2_UFCS_(,template,FUNCNAME CPP2_UFCS_REMPARENS TEMPARGS)(PARAM1,__VA_ARGS__)
743+ #define CPP2_UFCS_TEMPLATE_0_NONLOCAL(FUNCNAME,TEMPARGS,PARAM1) CPP2_UFCS_(,template,FUNCNAME CPP2_UFCS_REMPARENS TEMPARGS)(PARAM1)
744+ #endif
782745
783746
784747// -----------------------------------------------------------------------
@@ -847,17 +810,17 @@ auto is( X const& ) -> bool {
847810
848811template < typename C, typename X >
849812 requires (
850- ( std::is_base_of_v<X, C> ||
851- ( std::is_polymorphic_v<C> && std::is_polymorphic_v<X>)
813+ ( std::is_base_of_v<X, C> ||
814+ ( std::is_polymorphic_v<C> && std::is_polymorphic_v<X>)
852815 ) && !std::is_same_v<C,X>)
853816auto is ( X const & x ) -> bool {
854817 return Dynamic_cast<C const *>(&x) != nullptr ;
855818}
856819
857820template < typename C, typename X >
858821 requires (
859- ( std::is_base_of_v<X, C> ||
860- ( std::is_polymorphic_v<C> && std::is_polymorphic_v<X>)
822+ ( std::is_base_of_v<X, C> ||
823+ ( std::is_polymorphic_v<C> && std::is_polymorphic_v<X>)
861824 ) && !std::is_same_v<C,X>)
862825auto is ( X const * x ) -> bool {
863826 return Dynamic_cast<C const *>(x) != nullptr ;
@@ -1462,7 +1425,7 @@ inline auto to_string(std::string const& s) -> std::string const&
14621425
14631426template <typename T>
14641427inline auto to_string (T const & sv) -> std::string
1465- requires (std::is_convertible_v<T, std::string_view>
1428+ requires (std::is_convertible_v<T, std::string_view>
14661429 && !std::is_convertible_v<T, const char *>)
14671430{
14681431 return std::string{sv};
0 commit comments