First of all, a template.
Index Pattern:
template<unsigned... Is> struct indexes {typedef indexes<Is...> type;};
template<unsigned Max, unsigned... Is> struct make_indexes:make_indexes<Max-1, Max-1, Is...> {};
template<unsigned... Is> struct make_indexes<0, Is...>:indexes<Is...> {};
A helper class that allows you to build a proxy server without naming the enclosing class:
template<int I, typename... Args>
struct inner_helper {
std::tuple<Args...> args;
template<typename T, unsigned... Is>
T construct(indexes<Is...>) && {
return { std::forward<Args>(std::get<Is>(args))... };
}
template<typename T>
T construct() && {
return std::move(*this).template construct<T>( make_indexes<sizeof...(Args)>() );
}
};
, , . , inner<3> , :
template<int I, typename... Args>
inner_helper<I, Args...> inner( Args&&... args ) {
return {std::forward<Args>(args)...};
}
testclass . inner_helper<int, Args...> inner<int> Args..., inner<int>:
template<class T>
struct testclass
{
template<int I>
class inner {};
template<int I>
void f(inner<I> ) {}
template<int I, typename... Args>
void f(inner_helper<I, Args...> h) {
return f( std::move(h).template construct<inner<I>>() );
}
};
, :
int main()
{
testclass<bool> test;
test.f(inner<3>());
return 0;
}
, (inner<3>()), inner<3> ( ) f(inner<I>).
, inner<I> inner<I>.
, inner<I> , , . , SCARY ++, ( sortof) .