boost::begin
References
Headers
boost::begin
is available by including
any of the following headers:
boost/range/begin.hpp
orboost/range/algorithm.hpp
orboost/range/algorithm_ext.hpp
orboost/range/distance.hpp
orboost/range/atl.hpp
orboost/range/mfc.hpp
orboost/range/numeric.hpp
orboost/range/functions.hpp
orboost/range/iterator_range_core.hpp
orboost/range/iterator_range_io.hpp
orboost/range/counting_range.hpp
orboost/range/any_range.hpp
orboost/range.hpp
orboost/range/adaptors.hpp
orboost/range/rend.hpp
orboost/range/join.hpp
orboost/range/size.hpp
orboost/range/concepts.hpp
orboost/range/sub_range.hpp
orboost/range/empty.hpp
Examples
general.cpp
#include <string>
#include <vector>
#include <boost/range.hpp>
int main() {
std::string str = "abcde";
std::vector<int> vec = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
// Convert ranges into begin/end iterators.
// Mainly useful when writing range-based wrappers for functions that take
// begin/end iterators as arguments.
auto str_begin = boost::begin(str);
auto str_end = boost::end(str);
auto vec_rbegin = boost::rbegin(vec);
auto vec_rend = boost::rend(vec);
auto str_cbegin = boost::const_begin(str);
auto str_cend = boost::const_end(str);
auto vec_crbegin = boost::const_rbegin(vec);
auto vec_crend = boost::const_rend(vec);
// Suppress unused variable warnings.
(void)str_begin; (void)str_end;
(void)vec_rbegin; (void)vec_rend;
(void)str_cbegin; (void)str_cend;
(void)vec_crbegin; (void)vec_crend;
return 0;
}
Output:
Boost Range for Humans
This reference is part of Boost Range for Humans. Click the link to the overview.