This function is included in the "boost/algorithm/string" library. This library contains some brilliant methods which help in accomplishing string manipulations that are lacking in STL library.
This function is used to join various input strings. It joins the given input strings into one long string by adding a seperator between the strings i.e., the strings are concatenated by a seperator. The strings to be joined are provided in a container. Popularly used output containers are std::vector<std::string> or std::list<boost::iterator_range<std::string::iterator>>
input_container : a container which holds the input strings
seperator : A constant (string) that seperates the joined strings
There is another variant present join_if() wich joins the strings if they satisfy a given predicate condition i.e., only those strings are joined that satisfy a given condition. The predicate maybe any library function or maybe specified by the user.
SAMPLE CODE :
using namespace std;
using namespace boost::algorithm;
string str1 = "Hello";
string str2 = "how are you?";
string str3 = "This is boost";
string str4 = join(v1," ");
string str5 = join(v1,"-");
string str6 = join(v1,"##");
In the first case we are joining the three strings with a whitespace in between. In second case we are using '-' to seperate the joined strings. Whereas in the third case we are using a string "##".