O
Olav
Hi
I wonder if it is possible to have templates expand based on constness,
something like:
template<typename A, typename B>copy( A &a, B &b);
becoming:
copy( const class AClass &a, class BClass &b );
or
copy( class AClass &a, const class BClass &b );
based on arguments.
The purpose of this would be to be able to write something like
template<typename A, typename B>copy( A &a, B &b)
{
copy( a.name, b.name);
copy( a.value, b.value)
}
And have the constness of the arguments decide the direction.
Adding a third parameter specifying direction would be OK.
The main thing is to be able to use consting without const_cast's.
Thanks
Olav
I wonder if it is possible to have templates expand based on constness,
something like:
template<typename A, typename B>copy( A &a, B &b);
becoming:
copy( const class AClass &a, class BClass &b );
or
copy( class AClass &a, const class BClass &b );
based on arguments.
The purpose of this would be to be able to write something like
template<typename A, typename B>copy( A &a, B &b)
{
copy( a.name, b.name);
copy( a.value, b.value)
}
And have the constness of the arguments decide the direction.
Adding a third parameter specifying direction would be OK.
The main thing is to be able to use consting without const_cast's.
Thanks
Olav