Both string_ref in boost and string_span in GSL doesn't define constructor that takes a pair of iterator. What is the reason of this decision ?
Usually it's not a big deal, I can just create string_ref like this :
boost::string_ref s(start, std::distance(start, finish));
but the reason I want constructor that take a pair of iterators is because I have code that look like this:
template<typename Type, typename Iterator>
void func(const Iterator& begin, const Iterator& end)
{
Type s(begin, end);
//do stuff with s
}
Currently, I can call it like this :
func<std::string>(start, finish)
I want to change it to :
func<boost::string_ref>(start, finish) //compile error
but that code won't compile because the lack of constructor taking a pair of iterator in string_ref
std::string::iterator
? Becausestring_ref
references an existing string, so you can't construct it from thin air. – Coumarinboost::string_ref::iterator
:). – Prorogue