3

This is a follow-up to the following question: SFINAE in variadic constructor

I wrote that some code such as

template<typename... Args>
StrongAlias(Args&&... args) noexcept(noexcept(T(std::declval<Args>()...)))
    : value(std::forward<Args>(args)...) {}

would disable the StrongAlias constructor in the case where T isn't constructible from the argument types, but another user told me that this wouldn't work because the exception specification isn't part of the immediate context.

Is the exception specification not part of the immediate context? I can't see why this would be the case.

Brian Bi
  • 111,498
  • 10
  • 176
  • 312

1 Answers1

1

As pointed out by T.C. in comment, no. Per [temp.deduct]/7:

[ Note: The equivalent substitution in exception specifications is done only when the noexcept-specifier is instantiated, at which point a program is ill-formed if the substitution results in an invalid type or expression. — end note ]

L. F.
  • 19,445
  • 8
  • 48
  • 82