tag::snippet_strings_5[]
| 261 | |
| 262 | // tag::snippet_strings_5[] |
| 263 | string greeting( string_view first_name, string_view last_name ) |
| 264 | { |
| 265 | const char hello[] = "Hello, "; |
| 266 | const std::size_t sz = first_name.size() + last_name.size() + sizeof(hello) + 1; |
| 267 | |
| 268 | string js; |
| 269 | js.reserve(sz); |
| 270 | |
| 271 | char* p = std::copy( hello, hello + sizeof(hello) - 1, js.data() ); |
| 272 | p = std::copy( first_name.begin(), first_name.end(), p ); |
| 273 | *p++ = ' '; |
| 274 | p = std::copy( last_name.begin(), last_name.end(), p ); |
| 275 | *p++ = '!'; |
| 276 | |
| 277 | js.grow( sz ); |
| 278 | return js; |
| 279 | } |
| 280 | // end::snippet_strings_5[] |
| 281 | |
| 282 | void |