A
Alexander Malkis
//Consider:
class A { /*...*/ };
template<class T> class list {/*... */ };
void f(const list<const A*> lst) { /*...doesn't change the arg...*/ }
void g(list<A*> lst) {
f(lst); //Intuitively ok, but compiler rejects.
}
/* Compiler says:
error: conversion from `list<A*>' to non-scalar type `list<const A*>'
requested
Cast doesn't help either. What to do?
*/
class A { /*...*/ };
template<class T> class list {/*... */ };
void f(const list<const A*> lst) { /*...doesn't change the arg...*/ }
void g(list<A*> lst) {
f(lst); //Intuitively ok, but compiler rejects.
}
/* Compiler says:
error: conversion from `list<A*>' to non-scalar type `list<const A*>'
requested
Cast doesn't help either. What to do?
*/