I have this function definition in my code:
template <
class CharT,
class Traits = std::char_traits<CharT>,
class Allocator = std::allocator<CharT>
> std::basic_string<CharT, Traits, Allocator> bytes2string(const Bytes& bytes)
{
// do work ...
}
And when I try to call the function like this:
int main()
{
Bytes bytes{'H', 'e', 'l', 'l', 'o'};
std::string str = bytes2string(bytes); // error
return 0;
}
I am met with the following error:
error:
no matching function for call to 'bytes2string'
note:
candidate template ignored: couldn't infer template argument 'CharT'
> std::basic_string<CharT, Traits, Allocator> bytes2string(const Bytes& bytes)
I'm pretty sure it should work but alas, it doesn't. Also Bytes is just a std::vector<char> in case anyone wanted to know.