C ++ 0xでは、SFINAEルールが簡略化され、演繹の「即時コンテキスト」で発生する無効な式または型がコンパイラエラーではなく、演繹失敗(SFINAE)になります。
私の質問はこれです:
私がオーバーロードされた関数のアドレスを取り、それを解決できない場合、その失敗は演繹の直接の文脈でですか?
(つまり、ハードエラーですか、それとも解決できない場合はSFINAEですか)?
サンプルコードは次のとおりです。
struct X
{
// template<class T> T* foo(T,T); // lets not over-complicate things for now
void foo(char);
void foo(int);
};
template<class U> struct S
{
template<int> struct size_map
{ typedef int type; };
// here is where we take the address of a possibly overloaded function
template<class T> void f(T,
typename size_map<sizeof(&U::foo)>::type* = 0);
void f(...);
};
int main()
{
S<X> s;
// should this cause a compiler error because 'auto T = &X::foo' is invalid?
s.f(3);
}
Gcc 4.5は、これがコンパイラエラーであると述べており、clangはアサーション違反を吐き出します。
関心のあるいくつかの関連する質問があります:
FCD-C ++ 0xは、ここで何が起こるべきかを明確に指定していますか?
コンパイラはこのコードを拒否するのは間違っていますか?
演繹の「即時コンテキスト」をもう少し適切に定義する必要がありますか?
ありがとう!