deduction guides for std::basic_string

From cppreference.com
< cpp‎ | string‎ | basic string
 
 
 
std::basic_string
 
Defined in header <string>
template<class InputIt, class Alloc = std::allocator<

                          typename std::iterator_traits<InputIt>::value_type>>
basic_string(InputIt, InputIt, Alloc = Alloc())
-> basic_string<typename std::iterator_traits<InputIt>::value_type,
                std::char_traits<typename std::iterator_traits<InputIt>::value_type>,

                Alloc>;
(since C++17)


This deduction guide is provided for std::basic_string to allow deduction from an iterator range. This overload only participates in overload resolution if InputIt satisfies InputIterator and Alloc satisfies Allocator

Example

#include <string>
#include <vector>
int main() {
   std::vector<char> v = {'a', 'b', 'c'};
   std::basic_string s(v.begin(), v.end()); // uses explicit deduction guide
}