I am using a sequence of string from this link: here
template<typename Char, Char... Cs>
struct char_sequence
{
static constexpr const Char c_str[] = {Cs..., 0};
};
// That template uses the extension
template<typename Char, Char... Cs>
constexpr auto operator"" _cs() -> char_sequence<Char, Cs...> {
return {};
}
Then, I would make a call :
call_lib("Test"_cs);
where
template<char... Cs>
void call_lib(char_sequence<char, Cs...> url){
const_str(url.c_str); // this gives an error
}
// a Class from library
class const_str{
const char* const begin_;
template<unsigned N>
constexpr const_str(const char (&arr)[N]):
begin_(arr);
{
}
}
The error when constructing the class const_str
error: no matching conversion for functional-style cast from 'const char const[]' to 'const_str' const_str(url.c_str);
The complainer then complains of no matching copy constructor or move constructor (This is expected since this is not the one we need for constructing it). However, the other note from the compiler is:
note: candidate template ignored: could not match 'const char' against 'const char'
which is referring to the template constructor template<unsigned N> constexpr const_str(const char (&arr)[N])
Why is the compiler saying that it could not match const char to const char. It sounds a bit counter intuitive.
How can I solve this problem without having to edit the class const_str