I have a class that takes a template type parameter (tTRAIT). I want to friend a template type member alias of tTRAIT, but I can't figure out the syntax. (Is this even possible?).
template <bool bBOOL>
struct SFoo {};
struct STrait
{
template <bool bBOOL>
using TFoo = SFoo<bBOOL>;
};
template <typename tTRAIT>
struct SBar
{
template <bool bBOOL>
friend typename tTRAIT::template TFoo<bBOOL>;
};
SBar<STrait> bar;
Clang's error (on the friend
line) is:
error: friend type templates must use an elaborated type
I have tried exhausting all possible combinations I can think of:
friend tTRAIT::TFoo;
friend tTRAIT::template TFoo;
friend typename tTRAIT::TFoo;
friend typename tTRAIT::template TFoo;
template <bool bBOOL> friend tTRAIT::TFoo;
template <bool bBOOL> friend tTRAIT::TFoo<bBOOL>;
template <bool bBOOL> friend tTRAIT::template TFoo;
template <bool bBOOL> friend tTRAIT::template TFoo<bBOOL>;
template <bool bBOOL> friend typename tTRAIT::TFoo;
template <bool bBOOL> friend typename tTRAIT::TFoo<bBOOL>;
template <bool bBOOL> friend typename tTRAIT::template TFoo;
template <bool bBOOL> friend typename tTRAIT::template TFoo<bBOOL>;
I have also tried using using
, but it doesn't seem to help.
As an ugly hack (which only works for bool parameters), I can get it to work by friending each specialization manually.
friend typename tTRAIT::template TFoo<false>;
friend typename tTRAIT::template TFoo<true >;
But that's yucky.
Does anyone know how to do this, or if this can be done?
Aucun commentaire:
Enregistrer un commentaire