Code:
#include <iostream>
#include <string>
struct empty_type{};
template
<
typename node_F = empty_type,
typename list_F = empty_type
>
struct reference_list
{
typedef reference_list<node_F, list_F> type;
reference_list
(
const node_F & n_f,
const list_F & l_f
):
n_m(n_f),
l_m(l_f)
{
}
template
<
typename type_FR
>
typename reference_list<type_FR, typename reference_list<node_F, list_F>::type>::type operator ,
(
const type_FR & f
)
{
return(typename reference_list<type_FR, typename reference_list<node_F, list_F>::type>::type(f, *this));
}
const node_F & n_m;
const list_F & l_m;
};
template
<
typename node_F
>
struct reference_list<node_F, empty_type>
{
typedef reference_list<node_F, empty_type> type;
reference_list
(
const node_F & n_f
):
n_m(n_f)
{
}
template
<
typename type_FR
>
typename reference_list<type_FR, typename reference_list<node_F, empty_type>::type>::type operator ,
(
const type_FR & f
)
{
return(typename reference_list<type_FR, typename reference_list<node_F, empty_type>::type>::type(f, *this));
}
const node_F & n_m;
};
template <> struct reference_list<empty_type, empty_type>
{
typedef reference_list<empty_type, empty_type> type;
reference_list()
{
}
template
<
typename type_FR
>
typename reference_list<type_FR, empty_type>::type operator ,
(
const type_FR & f
)
{
return(typename reference_list<type_FR, empty_type>::type(f));
}
};
void do_something
(
const std::string & f,
int x_f,
int y_f,
int size_f
)
{
std::cout << "std::string:(" << f << ") X:(" << x_f << ") Y:(" << y_f << ") Size:(" << size_f << ")\n";
}
void do_something
(
const int & f,
int x_f,
int y_f,
int size_f
)
{
std::cout << "int:(" << f << ") X:(" << x_f << ") Y:(" << y_f << ") Size:(" << size_f << ")\n";
}
void do_something
(
const double & f,
int x_f,
int y_f,
int size_f
)
{
std::cout << "double:(" << f << ") X:(" << x_f << ") Y:(" << y_f << ") Size:(" << size_f << ")\n";
}
void do_something
(
const float & f,
int x_f,
int y_f,
int size_f
)
{
std::cout << "float:(" << f << ") X:(" << x_f << ") Y:(" << y_f << ") Size:(" << size_f << ")\n";
}
template
<
typename node_F
>
void do_something
(
const node_F & f,
int x_f,
int y_f,
int size_f
)
{
std::cout << "Data:(" << f << ") X:(" << x_f << ") Y:(" << y_f << ") Size:(" << size_f << ")\n";
}
template
<
typename node_F
>
void do_something
(
const reference_list<node_F, empty_type> & f,
int x_f,
int y_f,
int size_f
)
{
do_something(f.n_m, x_f, y_f, size_f);
}
template
<
typename node_F,
typename list_F
>
void do_something
(
const reference_list<node_F, list_F> & f,
int x_f,
int y_f,
int size_f
)
{
do_something(f.l_m, x_f, y_f, size_f);
do_something(f.n_m, x_f, y_f, size_f);
}
typedef reference_list<> arguments_list;
arguments_list join;
int main()
{
do_something((join, std::string("Hello"), ',', ' ' , std::string("World"), '!', 1, 2.0, 3.0f), 10, 10, 10);
return(0);
}