Questions tagged [string-view]

A string_view is a C++ class template that is a non-owning reference to a string.

Reference: http://en.cppreference.com/w/cpp/experimental/basic_string_view

215 questions
-1
votes
2 answers

Are two std::string_views refering to equal-comparing string literal always also equal?

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…
-1
votes
1 answer

Why should i use std::string_view instead of const char*?

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…
-1
votes
1 answer

using string_view to look up in unordered_map

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…
echo Lee
  • 191
  • 1
  • 2
  • 10
-4
votes
2 answers

std::string_view with C Fuction

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() { …
JuliusCaesar
  • 341
  • 3
  • 14
-4
votes
1 answer

basic_string to basic_string_view Implicit Conversion... ughhh why?

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…
user9816683
  • 105
  • 4
1 2 3
14
15