-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringView2.cpp
More file actions
48 lines (34 loc) · 1 KB
/
StringView2.cpp
File metadata and controls
48 lines (34 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* \file main.cpp
* \brief std::string_view
*
* \todo
*
* A non-owning reference to a string. Useful for providing an abstraction on top of strings
* (e.g. for parsing).
*/
#include <StdStream/StdStream.h>
#include <StdTest/StdTest.h>
#include <Stl.h>
//-------------------------------------------------------------------------------------------------
int main(int, char **)
{
// Regular strings.
std::string_view cppstr {"foo"};
// Wide strings.
std::wstring_view wcstr_v {L"baz"};
// Character arrays.
char array[3] = {'b', 'a', 'r'};
std::string_view array_v(array, std::size(array));
std::string str {" trim me"};
std::string_view v {str};
v.remove_prefix(std::min(v.find_first_not_of(" "), v.size()));
// str; " trim me"
// v; "trim me"
std::cout << STD_TRACE_VAR(str) << std::endl;
std::cout << STD_TRACE_VAR(v) << std::endl;
return EXIT_SUCCESS;
}
//-------------------------------------------------------------------------------------------------
#if OUTPUT
#endif