Un'espressione tra parentesi con identificatori noexcept
partecipa a SFINAE durante la risoluzione di sovraccarico dei modelli di funzione?SFINAE e identificatore noex
Voglio fare un wrapper per aggregati e vogliono il predicato std::is_constructible
funzioni correttamente per esso:
template< typename type >
struct embrace
: type
{
template< typename ...arguments >
embrace(arguments &&... _arguments) noexcept(noexcept(type{std::forward<arguments>(_arguments)...}))
: type{std::forward<arguments>(_arguments)...} // braces
{ ; }
};
int
main()
{
struct S { int i; double j; }; // aggregate
using E = embrace<S>;
E b(1, 1.0); // "parentheses"-constructible => can be used as usual types
b.i = 1; b.j = 2.0; // accessible
static_assert(std::is_constructible< E, int, double >{});
static_assert(std::is_constructible< E, struct B >{}); // want hard error here
return EXIT_SUCCESS;
}
Ma il mio tentativo di utilizzare noexcept
operatore all'interno noexcept
specifica per abilitare SFINAE è fallito, e il costruttore su modelli accetta tutto ciò che è passato ad esso. Come può essere limitato il costruttore?
Non è consentito dallo Standard specializzare alcun predicato da <type_traits>
. Come gestire i c-tor che accettano i pacchetti di parametri modello variadic e SFINAE in generale? C'è un impasse e un difetto linguistico intrinseco?
Che compilatore è questo? – ThomasMcLeod
@ThomasMcLeod [clang 3.7] (http://coliru.stacked-crooked.com/a/46c26922bef7a4f7) – Orient
@ThomasMcLeod * g ++ * restituisce un errore grave all'inizio (nel c-tor stesso e non in un SFINAE). – Orient