std::basic_string
: cppreference.com
<tbody>
</tbody>
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>; |
(1) | (C++17) |
template<class CharT, class Traits, class Alloc = std::allocator<CharT>> explicit basic_string(std::basic_string_view<CharT, Traits>, const Alloc& = Alloc()) -> basic_string<CharT, Traits, Alloc>; |
(2) | (C++17) |
template<class CharT, class Traits, class Alloc = std::allocator<CharT>>> basic_string(std::basic_string_view<CharT, Traits>, typename /*see below*/::size_type, typename /*see below*/::size_type, const Alloc& = Alloc()) -> basic_string<CharT, Traits, Alloc>; |
(3) | (C++17) |
: LegacyInputIterator Allocator Alloc::value_type std::declval<Alloc&>().allocate(std::size_t{}) well-formed
(2-3) std::basic_string_view std::basic_string
C++
| DR | |||
|---|---|---|---|
| LWG 3075 | C++17 | deduction from basic_string_view was unsupported (exacerbated by LWG issue 2946)
|
deduction guides added |
Run this code
#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
}