> Sukender wrote:
>> Hi Robert, hi all,
>>
>> "const T *v": When T is a function, I guess the compiler reads "pointer to a 
>> const function" instead of "const pointer to a function".
> That's not specific to functions, as "const C *c" where C is a class
> means the same: c is a pointer to a const instance of C. If you want a
> const pointer you would have to write "C *const c".
>
> Paul

Hi Robert and Paul,

Yes, that sounds logical when T is a class to give the "const object 
pointer/reference" method. However, it's useless for functions. Actually, the 
code would look like:

#if T is a not a function
    Value::Value(const T *v) { ... }
#endif

Of course, we can't do *that* simple. If the whole "Value" class was templated, 
we could partially specialize the templated class (= removing the 
Value::Value(const T *v) definition in the specialization when T is a 
function). But this is not the case.

May we use something similar to boost::add_const<> type traits then? Something 
that adds a "const" only if possible:
    template<typename T> Value(add_const<T>::type *v);
But I don't understand one point with functions: why don't the compiler 
complain about having twice the same constructor then, since we have 
"Value::Value(const T *v)" and "Value::Value(T *v)", and that the const is 
ignored?
If the last point is not a problem, then I suggest we use an "add_const<>"-like 
solution.

Sukender
PVLE - Lightweight cross-platform game engine - http://pvle.sourceforge.net/
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to