#include <iostream>
#include <utility>
using namespace std;

template<typename X>
struct thing {
};


template<typename> struct traits {};
template<
 template<class>class T,
 typename A>
struct traits<T<A>> {
 using param = A;
 template<typename X>
 using templ = T<X>;
};


template<typename Y>
decltype (auto) g(Y&& t) {
 // This is ugly, but well ...
 using trait = traits<typename std::remove_reference<Y>::type>;
 using A = typename trait::param;
 // using it, not as simple as T<A>, but at least it works
 typename trait::template templ<A> copy{t};
 typename trait::template templ<void> other;
 A data;
 return std::forward<Y>(t);
}

int main(int, char**) {
 thing<int> it {};
 g(thing<int> {});
 g(it);
 return 0;
}