std::string s1 {“Modern C++”, 3} vs std::string s1 {str, 3}
From: https://en.cppreference.com/w/cpp/string/basic_string/basic_string std::string s1 {“Modern C++”, 3}; Uses the following constructor: basic_string( const CharT* s, size_type count, const Allocator& alloc = Allocator() ); So takes 3 chars to get Mod. std::string s2 {str, 3}; will use the following constructor: basic_string( const basic_string& other, size_type pos, const Allocator& alloc = Allocator() ); So taking the string … Read more