
Add deduction guides to `valarray` and `scoped_allocator_adaptor`. This largely finishes implementation of the paper: * deduction guides for other classes mentioned in the paper were implemented previously (see the list below); * deduction guides for several classes contained in the proposal (`reference_wrapper`, `lock_guard`, `scoped_lock`, `unique_lock`, `shared_lock`) were removed by [LWG2981](https://wg21.link/LWG2981). Also add deduction guides to the synopsis for the few classes (e.g. `pair`) where they were missing. The only part of the paper that isn't fully implemented after this patch is making sure certain deduction guides don't participate in overload resolution when given incorrect template parameters. List of significant commits implementing the other parts of P0433 (omitting some minor fixes): * [pair](af65856eec
) * [basic_string](6d9f750dec
) * [array](0ca8c0895c
) * [deque](dbb6f8a817
) * [forward_list](e076700b77
) * [list](4a227e582b
) * [vector](df8f754792
) * [queue/stack/priority_queue](5b8b8b5dce
) * [basic_regex](edd5e29cfe
) * [optional](f35b4bc395
) * [map/multimap](edfe8525de
) * [set/multiset](e20865c387
) * [unordered_set/unordered_multiset](296a80102a
) * [unordered_map/unordered_multimap](dfcd4384cb
) * [function](e1eabcdfad
) * [tuple](1308011e1b
) * [shared_ptr/weak_ptr](83564056d4
) Additional notes: * It was revision 2 of the paper that was voted into the Standard. P0433R3 is a separate paper that is not part of the Standard. * The paper also mandates removing several `make_*_searcher` functions (e.g. `make_boyer_moore_searcher`) which are currently not implemented (except in `experimental/`). * The `__cpp_lib_deduction_guides` feature test macro from the paper was accidentally omitted from the Standard. Differential Revision: https://reviews.llvm.org/D112510
56 lines
2.1 KiB
C++
56 lines
2.1 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// <string>
|
|
// UNSUPPORTED: c++03, c++11, c++14
|
|
|
|
// template<class InputIterator,
|
|
// class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
|
|
// basic_string(InputIterator, InputIterator, Allocator = Allocator())
|
|
// -> basic_string<typename iterator_traits<InputIterator>::value_type,
|
|
// char_traits<typename iterator_traits<InputIterator>::value_type>,
|
|
// Allocator>;
|
|
//
|
|
// The deduction guide shall not participate in overload resolution if InputIterator
|
|
// is a type that does not qualify as an input iterator, or if Allocator is a type
|
|
// that does not qualify as an allocator.
|
|
|
|
|
|
#include <string>
|
|
#include <iterator>
|
|
#include <cassert>
|
|
#include <cstddef>
|
|
|
|
#include "test_macros.h"
|
|
|
|
class NotAnIterator {};
|
|
|
|
template <typename T>
|
|
struct NotAnAllocator { typedef T value_type; };
|
|
|
|
int main(int, char**)
|
|
{
|
|
{ // Not an iterator at all
|
|
std::basic_string s1{NotAnIterator{}, NotAnIterator{}, std::allocator<char>{}}; // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'basic_string'}}
|
|
}
|
|
{ // Not an input iterator
|
|
std::basic_string<char16_t> s0;
|
|
std::basic_string s1{std::back_insert_iterator(s0), // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'basic_string'}}
|
|
std::back_insert_iterator(s0),
|
|
std::allocator<char16_t>{}};
|
|
}
|
|
{ // Not an allocator
|
|
const wchar_t* s = L"12345678901234";
|
|
(void)s;
|
|
std::basic_string s1{s, s+10, NotAnAllocator<wchar_t>{}}; // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'basic_string'}}
|
|
}
|
|
|
|
|
|
return 0;
|
|
}
|