Conditional nothrow/safe/nogc/etc?
Matt Elkins via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jan 29 21:17:36 PST 2016
Is there any way to specify that a generic function is
conditionally nothrow (or other function decorators), based on
whether the template instantiation is nothrow? I'm looking for
something akin to C++'s noexcept(noexcept(<expr>)), e.g.:
template <class T> void foo() noexcept(noexcept(T())) {}
I don't see anything about it on the functions grammar page
(https://dlang.org/spec/function.html). I do see something to do
with nothrow_ on the std.traits page, but I'm not sure how to use
it to achieve this or whether that is the right approach.
My actual use case is a non-generic method opAssign inside of a
generic struct.
More information about the Digitalmars-d-learn
mailing list