• For what is this class good for ?

    From Bonita Montero@3:633/10 to All on Wed Oct 8 18:48:34 2025
    template<typename First, typename ... Further>
    struct exc_xguard_unpack_last
    {
    using further = std::tuple<Further *...>;
    using type = typename exc_xguard_unpack_last<Further ...>::type;
    };

    template<typename Last>
    struct exc_xguard_unpack_last<Last>
    {
    using type = Last;
    };

    template<typename ... PassThrough>
    struct exc_xguard
    {
    template<typename Func, typename Nested>
    FORCEINLINE auto operator ()( Func func, Nested nested ) const
    {
    static_assert( sizeof ...(PassThrough) >= 1 );
    try
    {
    using return_type = std::invoke_result_t<Func>;
    return [&]<typename ... Pass>( this auto const &self, std::tuple<Pass
    *...> ) L_FORCEINLINE -> return_type
    {
    try
    {
    if constexpr( sizeof ...(Pass) == 1 )
    return func();
    else
    return self( typename exc_xguard_unpack_last<Pass ...>::further() );
    }
    catch( typename exc_xguard_unpack_last<Pass ...>::type & )
    {
    throw;
    }
    }( std::tuple<PassThrough *...>() );
    }
    catch( ... )
    {
    throw nested();
    }
    }
    };



    --- PyGate Linux v1.0
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Wed Oct 8 19:07:09 2025
    Am 08.10.2025 um 18:48 schrieb Bonita Montero:

    ...
    template<typename ... PassThrough>
    struct exc_xguard
    {
    ˙˙˙˙template<typename Func, typename Nested>
    ˙˙˙˙FORCEINLINE auto operator ()( Func func, Nested nested ) const
    ˙˙˙˙{
    ˙˙˙˙˙˙˙ static_assert( sizeof ...(PassThrough) >= 1 );
    ˙˙˙˙˙˙˙ try
    ˙˙˙˙˙˙˙ {
    ˙˙˙˙˙˙˙˙˙˙˙ using return_type = std::invoke_result_t<Func>;
    ˙˙˙˙˙˙˙˙˙˙˙ return [&]<typename ... Pass>( this auto const &self, std::tuple<Pass *...> ) L_FORCEINLINE -> return_type
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ {
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ try
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ {
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ if constexpr( sizeof ...(Pass) == 1 )
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ return func();
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ else
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ return self( typename exc_xguard_unpack_last<Pass ...>::further() );
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ }
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ catch( typename
    exc_xguard_unpack_last<Pass ...>::type & )
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ {
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ throw;
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ }
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ }( std::tuple<PassThrough *...>() );
    ˙˙˙˙˙˙˙ }
    ˙˙˙˙˙˙˙ catch( ... )
    ˙˙˙˙˙˙˙ {
    ˙˙˙˙˙˙˙˙˙˙˙ throw nested();
    ˙˙˙˙˙˙˙ }
    ˙˙˙˙}
    };



    I forget a throw_with_nested:

    template<typename ... PassThrough>
    struct exc_xguard
    {
    template<typename Func, typename Nested>
    FORCEINLINE auto operator ()( Func func, Nested nested ) const
    {
    static_assert( sizeof ...(PassThrough) >= 1 );
    try
    {
    using return_type = std::invoke_result_t<Func>;
    return [&]<typename ... Pass>( this auto const &self, std::tuple<Pass
    *...> ) L_FORCEINLINE -> return_type
    {
    try
    {
    if constexpr( sizeof ...(Pass) == 1 )
    return func();
    else
    return self( typename exc_xguard_unpack_last<Pass ...>::further() );
    }
    catch( typename exc_xguard_unpack_last<Pass ...>::type & )
    {
    throw;
    }
    }( std::tuple<PassThrough *...>() );
    }
    catch( ... )
    {
    std::throw_with_nested( nested() );
    }
    }
    };

    --- PyGate Linux v1.0
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From wij@3:633/10 to All on Thu Oct 9 01:45:22 2025
    On Wed, 2025-10-08 at 18:48 +0200, Bonita Montero wrote:
    template<typename First, typename ... Further>
    struct exc_xguard_unpack_last
    {
    using further = std::tuple<Further *...>;
    using type = typename exc_xguard_unpack_last<Further ...>::type;
    };

    template<typename Last>
    struct exc_xguard_unpack_last<Last>
    {
    using type = Last;
    };

    template<typename ... PassThrough>
    struct exc_xguard
    {
    template<typename Func, typename Nested>
    FORCEINLINE auto operator ()( Func func, Nested nested ) const
    {
    static_assert( sizeof ...(PassThrough) >= 1 );
    try
    {
    using return_type = std::invoke_result_t<Func>;
    return [&]<typename ... Pass>( this auto const &self, std::tuple<Pass

    *...> ) L_FORCEINLINE -> return_type
    {
    try
    {
    if constexpr( sizeof ...(Pass) == 1 )
    return func();
    else
    return self( typename exc_xguard_unpack_last<Pass ...>::further() );
    }
    catch( typename exc_xguard_unpack_last<Pass ...>::type & )
    {
    throw;
    }
    }( std::tuple<PassThrough *...>() );
    }
    catch( ... )
    {
    throw nested();
    }
    }
    };

    As usual, the code itself is meaningless (likely so?).
    What is the purpose of the codes, and useful in what environment/condition?

    C++ is expressive. But more importantly, expressive for what? If the author
    is
    not clear of the logic of his idea/concept, what would the 'expressive' mea
    n?
    That is the general C++ problem: It greatly helps writing obscure codes.


    --- PyGate Linux v1.0
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Thu Oct 9 05:47:11 2025
    Am 08.10.2025 um 19:45 schrieb wij:

    As usual, the code itself is meaningless (likely so?).
    What is the purpose of the codes, and useful in what environment/condition?

    C++ is expressive. But more importantly, expressive for what? If the author is
    not clear of the logic of his idea/concept, what would the 'expressive' mean? That is the general C++ problem: It greatly helps writing obscure codes.

    For skilled C++-developers the purpose is easy to guess from the source.


    --- PyGate Linux v1.0
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Tristan Wibberley@3:633/10 to All on Sat Oct 25 16:33:53 2025
    On 08/10/2025 17:48, Bonita Montero wrote some code in news:///0c64k6$1nqj1$1@raubtier-asyl.eternal-september.org

    Well, I don't really know all the new-fangled language-ending C++ stuff,
    but from my last point in C++, supposing the new stuff was by and for
    humans, many of whom are trying to capitalise on python and
    functional-paradigm programmers.

    Is it, perhaps, a very implementation specific routine for guaranteeing
    or measuring a supposed C-stack availability or quantity of available recursions, and maybe to run a function right at the end of the
    available stack? Does modern C++ throw an exception when at the end of
    the stack?

    Perhaps to add markers to detect programming errors, or to take
    advantage of programming errors, or to decide on what routines to offer,
    when to give up a naive recursive process, etc. perhaps the call will
    give for "func" an implementation specific assembler routine that
    detects proximity to the end of stack and raises a C++ exception.

    Seems to be the theme of the comp.* heirarchy at the moment.

    --
    Tristan Wibberley

    The message body is Copyright (C) 2025 Tristan Wibberley except
    citations and quotations noted. All Rights Reserved except that you may,
    of course, cite it academically giving credit to me, distribute it
    verbatim as part of a usenet system or its archives, and use it to
    promote my greatness and general superiority without misrepresentation
    of my opinions other than my opinion of my greatness and general
    superiority which you _may_ misrepresent. You definitely MAY NOT train
    any production AI system with it but you may train experimental AI that
    will only be used for evaluation of the AI methods it implements.


    --- PyGate Linux v1.5
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Sun Oct 26 15:16:07 2025
    Am 08.10.2025 um 18:48 schrieb Bonita Montero:
    template<typename First, typename ... Further>
    struct exc_xguard_unpack_last
    {
    ˙˙˙˙using further = std::tuple<Further *...>;
    ˙˙˙˙using type = typename exc_xguard_unpack_last<Further ...>::type;
    };

    template<typename Last>
    struct exc_xguard_unpack_last<Last>
    {
    ˙˙˙˙using type = Last;
    };

    template<typename ... PassThrough>
    struct exc_xguard
    {
    ˙˙˙˙template<typename Func, typename Nested>
    ˙˙˙˙FORCEINLINE auto operator ()( Func func, Nested nested ) const
    ˙˙˙˙{
    ˙˙˙˙˙˙˙ static_assert( sizeof ...(PassThrough) >= 1 );
    ˙˙˙˙˙˙˙ try
    ˙˙˙˙˙˙˙ {
    ˙˙˙˙˙˙˙˙˙˙˙ using return_type = std::invoke_result_t<Func>;
    ˙˙˙˙˙˙˙˙˙˙˙ return [&]<typename ... Pass>( this auto const &self, std::tuple<Pass *...> ) L_FORCEINLINE -> return_type
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ {
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ try
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ {
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ if constexpr( sizeof ...(Pass) == 1 )
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ return func();
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ else
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ return self( typename exc_xguard_unpack_last<Pass ...>::further() );
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ }
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ catch( typename
    exc_xguard_unpack_last<Pass ...>::type & )
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ {
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ throw;
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ }
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ }( std::tuple<PassThrough *...>() );
    ˙˙˙˙˙˙˙ }
    ˙˙˙˙˙˙˙ catch( ... )
    ˙˙˙˙˙˙˙ {
    ˙˙˙˙˙˙˙˙˙˙˙ throw nested();
    ˙˙˙˙˙˙˙ }
    ˙˙˙˙}
    };



    There's a bug inside that. Do you notice it ?

    --- PyGate Linux v1.5
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)