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 remove the head of the input string. It first identifies the head by taking first N characters , where N is given by the user. It then proceeds to remove the head of the input string.
input_string : an input string
N : An integer which specifies the number of characters to be considered as head.
(For N>=0, at most N characters are extracted. For N<0, size(Input)-|N| characters are extracted.)
erase_head() performs an inplace removal. There is another variation present erase_head_copy() which instead of doing an inplace removal, returns a copy of the modified string.
using namespace std;
using namespace boost::algorithm;
string str1 = "Hello and Welcome to Boost";
string str2 = "Apple Banana Mango Apple Banana Apple";
string str4 = "Hi Hi Hi Hi Hi Hi";
string str3 = erase_head_copy(str4,3);
As we can observe from the output we are first performing an inplace removal where we are removing the first 5 characters of the input string i.e., "Hello". In str3, we are storing the copy of the modified string i.e., inplace removal is not preformed.