I have an unordered_map which is supposed to mimic a filter, taking key and value as std::string_view respectively. Now say I want to compare two filters that have the same key-value-pairs: Will they always compare equal?
My thought is the…
In this tutorial i read that i should use std::string_view instead of C-style strings, but i didn't figure out why. String_view has many problems, such as null-terminator, so it looks useful only while passing as function parameter instead…
Say the following code:
unordered_map test_map;
string_view fake_str = "Mike";
test_map[fake_str]; // does not work. No viable overloaded operator[] for type...
test_map.at(fake_str); // works.
I think the purpose of string_view is to…
I'm using some C Leagacy Code within a C++ project.
On used C function looks like this
void Add_To_log(const * const char pString_1, const * const char pString_2, int number);
Now when I call this Functions from C++ Code like this
foo()
{
…
The C++ Standards Committee had an opportunity to make code safer with string_view but they opted to add implicit conversion from basic_string to basic_string_view.
So effectively, they're saying this
// No worries, everyone always reads the…