Hermann wrote:
I remember there was a trick to get the type of a anonymous variable
(like a boost::lambda functor or a boost::list_of object) so you can
store it in a variable.
You had to generate a specific compilation error and then look for the
type definition in the error text that the compiler outputs (or
somethig like that).
Does anyone know exactly how to do it??
Do you mean something like this
template< typename T >
i_have_no_idea<T>::some_type f(T);
template< typename T >
void g(T o)
{
what_is_the_type tmp = f(o);
}
where you don't know 'what_is_the_type'?
Doesn't your compiler name the type in its complaints
when you try to make 'tmp' a 'bool', 'int', 'std::string',
or 'foo'? I believe that, with my compiler, passing some
unknown type to something like this
template< typename T >
void dummy(T)
{
typedef typename T::some_thing_that_does_not_exist U;
}
(or an equivalent meta functions, if you're in compile-time
land) usually does the trick to get it to name 'T'.
Schobi