これは、リンクされたワーキングペーパーに記載されていない、クラス内のフレンド関数の戻り値の型推定に関する小さな実験です (両方のケースで Clang 3.4 SVN と g++ 4.8.1 を使用)。std=c++1y
#include <iostream>
struct A
{
int a_;
friend auto operator==(A const& L, A const& R)
{
return L.a_ == R.a_; // a_ is of type int, so should return bool
}
};
template<class T>
struct B
{
int b_;
friend auto operator==(B const& L, B const& R)
{
return L.b_ == R.b_; // b_ is of type int, so should return bool
}
};
using BI = B<int>;
int main()
{
std::cout << (A{1} == A{2}) << "\n"; // OK for Clang, ERROR for g++
std::cout << (BI{1} == BI{2}) << "\n"; // ERROR for both Clang and g++
}
質問: C++14 でサポートされているクラス内のフレンド関数の戻り値の型の自動推論はサポートされていますか?