Skip to content

Commit 7afb856

Browse files
string_trim(strip)_boost.cpp
1 parent b982ba5 commit 7afb856

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

string_trim(strip)_boost.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <boost/algorithm/string/trim.hpp>
2+
#include <boost/algorithm/string/trim_all.hpp>
3+
#include <iostream>
4+
5+
int main(){
6+
std::string str(" hello world! ");
7+
std::cout << "original: '" << str << "'" << std::endl;
8+
std::cout << "trimed from right: '" << boost::trim_right_copy(str) << "'" << std::endl;
9+
std::cout << "trimed from left: '" << boost::trim_left_copy(str) << "'" << std::endl;
10+
std::cout << "trimed from left and right: '" << boost::trim_all_copy(str) << "'" << std::endl;
11+
boost::trim_right(str);
12+
std::cout << "trimed from right(in-place): '" << str << "'" << std::endl;
13+
boost::trim_left(str);
14+
std::cout << "trimed from left(in-place): '" << str << "'" << std::endl;
15+
}
16+
17+
/*
18+
original: ' hello world! '
19+
trimed from right: ' hello world!'
20+
trimed from left: 'hello world! '
21+
trimed from left and right: 'hello world!'
22+
trimed from right(in-place): ' hello world!'
23+
trimed from left(in-place): 'hello world!'
24+
*/

0 commit comments

Comments
 (0)