Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:23

0001 /**
0002 name=string_viewTest ; gcc $name.cc -std=c++17 -lstdc++ -o /tmp/$name && /tmp/$name
0003 
0004 https://www.learncpp.com/cpp-tutorial/an-introduction-to-stdstring_view/
0005 
0006 **/
0007 
0008 
0009 #include <iostream>
0010 #include <string_view>
0011 
0012 int main()
0013 {
0014   std::string_view text{ "hello" }; // view the text "hello", which is stored in the binary
0015   std::string_view str{ text }; // view of the same "hello"
0016   std::string_view more{ str }; // view of the same "hello"
0017 
0018   std::cout << text << ' ' << str << ' ' << more << '\n';
0019 
0020   return 0;
0021 }