This function is similar to strtok in C. Input sequence is split into tokens, separated by separators. Separators are given by means of the predicate.
Template: split(Result, Input, PredicateT Pred); Parameters: Input: A container which will be searched. Pred: A predicate to identify separators. This predicate is supposed to return true if a given element is a separator. Result: A container that can hold copies of references to the substrings. Returns: A reference the result
Application : It is used to split a string into substrings which are separated by separators.
Input : boost::split(result, input, boost::is_any_of("\t")) input = "geeks\tfor\tgeeks" Output : geeks for geeks Explanation: Here in input string we have "geeks\tfor\tgeeks" and result is a container in which we want to store our result here separator is "\t".
geeks for geeks
Rated as one of the most sought after skills in the industry, own the basics of coding with our C++ STL Course and master the very concepts by intense problem-solving.
- Unordered Sets in C++ Standard Template Library
- Advanced C++ with boost library
- How to add "graphics.h" C/C++ library to gcc compiler in Linux
- The C++ Standard Template Library (STL)
- List in C++ Standard Template Library (STL)
- Deque in C++ Standard Template Library (STL)
- Map in C++ Standard Template Library (STL)
- Wide char and library functions in C++
- C Library math.h functions
- difftime() C library function
- snprintf() in C library
- <iterator> library in C++ STL
- Factorial of Large Number Using boost multiprecision Library
- <strings> library in C++ STL
- Generating large Fibonacci numbers using boost library
- Containers in C++ STL (Standard Template Library)
- <numeric> library in C++ STL
- <regex> library in C++ STL
- Check all the elements in an array are even using library in C++
- Pattern Searching using C++ library
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.