If what you want is just to turn a blind eye to some const issues, then you can use a conversion which blurs the distinction, i.e. makes char** and const char** interoperable:
template<class T>
class sloppy {};
// convert between T** and const T**
template<class T>
class sloppy<T**>
{
T** t;
public:
sloppy(T** mt) : t(mt) {}
sloppy(const T** mt) : t(const_cast<T**>(mt)) {}
operator T** () const { return t; }
operator const T** () const { return const_cast<const T**>(t); }
};
Then later in the program:
iconv(c, sloppy<char**>(&in) ,&inlen, &out,&outlen);
sloppy() takes a char**
or a const char*
and converts it to a char**
or a const char*
, whatever the second parameter of iconv demands.
UPDATE: changed to use const_cast and call sloppy not a as cast.