c++ - Access restrictions for template arguments -


the section n4296::14.3/3 [temp.arg] says:

the name of template-argument shall accessible @ point where it used template-argument. [ note: if name of template-argument accessible @ point used templateargument, there no further access restriction in the resulting instantiation corresponding template-parameter name used. —end note ]

all right, let's consider following example:

template <class t> class x{     static typename t::s ts; };  class y { private:     class vs{ class s{ }; };     x<vs> x; //1 }; 

demo

template argument template x in instantiation @ //1 class vs. now, standard said it's this:

the name of template-argument shall accessible @ point where it used template-argument.

class vs accessible @ point //1, therefore requirement held. inspite of fact standard said there's no further access restriction, code not compiled.

why code not compiled? based on section provided, should be compiled.

s private, try this:

template <class t> class x{    static typename t::s ts;  };   class y {  private:    class vs{ public: class s{ }; };    x<vs> x; //1  }; 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -