friend of a function std::enable_if

Hi,
I'm reimplementing the class std::tuple following this article: http://eli.thegreenplace.net/2014/variadic-templates-in-c/ . One point I'm stuck is how to declare the class to be friend of the function get<0>(t):

Function def:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
template<typename ... Args> class my_tuple{ }; // primary template
template<typename X, typename ... Args> class my_tuple<X, Args...>; // forward decl.

// switch for k != 0
// [...]

template <int k, typename ... Args >
typename std::enable_if< k == 0, typename _my_tuple_type< 0, my_tuple<Args...> >::type& >::type get(my_tuple<Args...>& t){
	return t.head;
}

template<typename X, typename ... Args>
class my_tuple<X, Args...> : public my_tuple<Args...>{
	typedef my_tuple<Args...> base_t;
	X head;

//      // it does not work
//	template <int tk, typename ... tArgs >
//	friend typename _my_tuple_type< 0, my_tuple<tArgs...> >::type get(my_tuple<tArgs...>);

	template <int tk, typename ... Args >
	friend typename std::enable_if< tk == 0, typename _my_tuple_type< 0, my_tuple<Args...> >::type& >::type get(my_tuple<Args...>&);
};

...



How should be treated std::enable_if in case of the friend decls? In the article this problem does not arise because the instance member is public.

Regards,
Dean

edit: the compiler is gcc 4.9.2 w/ c++11
Last edited on
Topic archived. No new replies allowed.