Date: Wed, 28 May 2025 12:18:37 +0100
On Wed, 28 May 2025 at 10:36, Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:
>
> There are times when I'm writing template code and I end up with
> 'noexcept' specifications something like:
>
> template<typename T>
> void Func(T&&) noexcept( noexcept( std::declval<T&>.clear() ) &&
> noexcept(std::declval<T&>.some_other_method() ) );
Why? Does the code calling Func even care? Will it do things
differently depending on whether Func can potentially throw, or is the
noexcept-specifier pointless?
>
> when what I really want is that 'T' would be some sort of class whose
> methods never throw.
>
> Would it be helpful at all to be able to mark a class or an individual
> object as 'noexcept'? Maybe something like:
>
> class noexcept MyClass { . . . };
>
> or maybe even mark an object:
>
> MyClass noexcept my_object;
>
> so that we get a compiler error if any of the class's methods are not
> marked as 'noexcept'?
>
> (I think marking the class would be a lot less work, as marking an
> object I think would mean adding a cv-qualifier to the language)
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Std-Proposals <std-proposals_at_[hidden]> wrote:
>
> There are times when I'm writing template code and I end up with
> 'noexcept' specifications something like:
>
> template<typename T>
> void Func(T&&) noexcept( noexcept( std::declval<T&>.clear() ) &&
> noexcept(std::declval<T&>.some_other_method() ) );
Why? Does the code calling Func even care? Will it do things
differently depending on whether Func can potentially throw, or is the
noexcept-specifier pointless?
>
> when what I really want is that 'T' would be some sort of class whose
> methods never throw.
>
> Would it be helpful at all to be able to mark a class or an individual
> object as 'noexcept'? Maybe something like:
>
> class noexcept MyClass { . . . };
>
> or maybe even mark an object:
>
> MyClass noexcept my_object;
>
> so that we get a compiler error if any of the class's methods are not
> marked as 'noexcept'?
>
> (I think marking the class would be a lot less work, as marking an
> object I think would mean adding a cv-qualifier to the language)
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Received on 2025-05-28 11:18:56