Hi!
I'm looking for some "lazy" version of boost::mpl::if_. I'm not very much
into MPL, so I
don't really know either if such a function exists in boost or whether it
can be easily
constructed.
Platform: VC++7.1
Thx in advance,
Agoston
This example shows you how it may cause problems that both "branches" of if_
get evaluated:
//------------------------------------------------------------
#include <iostream>
#include <vector>
#include
#include
using namespace std;
using namespace boost;
using namespace mpl;
template<typename T>
struct t_type
{
typedef typename if_<
is_arithmetic<T>,
T, typename T::value_type>::type // ERROR!
type;
};
int _tmain(int argc, _TCHAR* argv[])
{
cout << typeid(t_type<int>::type).name() << endl; // 'int'
cout << typeid(t_type::type).name()
<< endl; // 'double'
return 0;
}
//------------------------------------------------------------
Error message:
error C2825: 'T::value_type': cannot form a qualified name
see reference to class template instantiation 't_type<T>' being compiled
with
[
T=int
]