Skip to content

Commit d2dd8b0

Browse files
committed
[libc++] Prohibits initializer_list specializations.
This relies on Clang's no_specializations attribute which is not supported by GCC. Implements: - LWG2129: User specializations of std::initializer_list Fixes: #126270
1 parent e83ad81 commit d2dd8b0

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

libcxx/docs/Status/Cxx17Issues.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"`LWG2404 <https://wg21.link/LWG2404>`__","``mismatch()``\ 's complexity needs to be updated","2014-11 (Urbana)","|Complete|","",""
1313
"`LWG2408 <https://wg21.link/LWG2408>`__","SFINAE-friendly ``common_type``\ / ``iterator_traits``\ is missing in C++14","2014-11 (Urbana)","|Complete|","",""
1414
"`LWG2106 <https://wg21.link/LWG2106>`__","``move_iterator``\ wrapping iterators returning prvalues","2014-11 (Urbana)","|Complete|","",""
15-
"`LWG2129 <https://wg21.link/LWG2129>`__","User specializations of ``std::initializer_list``\ ","2014-11 (Urbana)","|Complete|","",""
15+
"`LWG2129 <https://wg21.link/LWG2129>`__","User specializations of ``std::initializer_list``\ ","2014-11 (Urbana)","|Complete|","21",""
1616
"`LWG2212 <https://wg21.link/LWG2212>`__","``tuple_size``\ for ``const pair``\ request <tuple> header","2014-11 (Urbana)","|Complete|","",""
1717
"`LWG2217 <https://wg21.link/LWG2217>`__","``operator==(sub_match, string)``\ slices on embedded '\0's","2014-11 (Urbana)","|Complete|","",""
1818
"`LWG2230 <https://wg21.link/LWG2230>`__","""see below"" for ``initializer_list``\ constructors of unordered containers","2014-11 (Urbana)","|Complete|","",""

libcxx/include/initializer_list

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ namespace std // purposefully not versioned
5959
# ifndef _LIBCPP_CXX03_LANG
6060

6161
template <class _Ep>
62-
class _LIBCPP_TEMPLATE_VIS initializer_list {
62+
class _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS initializer_list {
6363
const _Ep* __begin_;
6464
size_t __size_;
6565

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// UNSUPPORTED: c++03
10+
11+
// template<class E> class initializer_list;
12+
//
13+
// If an explicit specialization or partial specialization of initializer_list
14+
// is declared, the program is ill-formed.
15+
16+
#include <initializer_list>
17+
18+
// expected-error@+2 {{'initializer_list' cannot be specialized: Users are not allowed to specialize this standard library entity}}
19+
template <>
20+
class std::initializer_list<int> {};
21+
22+
// expected-error@+2 {{'initializer_list' cannot be specialized: Users are not allowed to specialize this standard library entity}}
23+
template <typename T>
24+
class std::initializer_list<T*> {};

0 commit comments

Comments
 (0)