[ Web Proxy ]
URL:
Viewing: http://ja.cppreference.com/cpp/string/basic_string/deduction_guides [Back]  [Original]

std::basic_string - cppreference.com
cppreference.com

std::basic_string

: cppreference.com
 
C++
(C++20)
(C++20)
(C++17)
(C++11)
(C++11)
(C++11)
 
 
std::basic_string
 
<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)
2-3) std::basic_string_view std::basic_string (3) size_type size_type Alloc Allocator

: 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

#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
}



Web Proxy Viewer  |  New URL  |  Original Page