次のようなコードがあります。
template <typename T, typename U> struct MyStruct {
T aType;
U anotherType;
};
class IWantToBeFriendsWithMyStruct
{
friend struct MyStruct; //what is the correct syntax here ?
};
テンプレートに友情を与える正しい構文は何ですか?
class IWantToBeFriendsWithMyStruct
{
template <typename T, typename U>
friend struct MyStruct;
};
VS2008 で動作し、MyStruct がクラスにアクセスできるようにします。
このサイトによると、正しい構文は
class IWantToBeFriendsWithMyStruct
{
template <typename T, typename U> friend struct MyStruct;
}