I'm having problems, and I'm wondering if this is normal or nor and if there's some workaround.
Consider:
mpl::type_name is a meta-template struct helper that helps in printing out names of the types since Microsoft's typeid.name() ignores const and reference identifiers on the types.Code:namespace mpl = Stuff::mpl; template<typename T> struct foo { typedef const T type; }; int main() { A a; a.x = 0; cout << mpl::type_name<foo<A&>::type>::name << endl; }
Regardless of that, this does not work as expected. You would expect it to return (or I would) const A&, but it doesn't. It's still the same old A&.
Visual Studio warns me:
Warning 1 warning C4181: qualifier applied to reference type; ignored g:\w00t\visual studio 2008\projects\temp\temp2.cpp 35
Which essentially means I cannot append const to a reference type.
So is there a way to add const to a reference type?
The idea is to do:
void foo(typename mpl::ArgumentHelper<T>::const_type Arg)
And const_type will be T if it's a native type and const T& if it's a class or struct.



LinkBack URL
About LinkBacks



