Index: include/array =================================================================== --- include/array +++ include/array @@ -72,6 +72,9 @@ const T* data() const noexcept; }; + template + array(T, U...) -> array; + template bool operator==(const array& x, const array& y); template @@ -354,6 +357,14 @@ }; +#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES +template && ...), void>::type + > +array(_Tp, _Args...) + -> array<_Tp, 1 + sizeof...(_Args)>; +#endif + template inline _LIBCPP_INLINE_VISIBILITY bool Index: test/std/containers/sequences/array/array.cons/deduct.fail.cpp =================================================================== --- test/std/containers/sequences/array/array.cons/deduct.fail.cpp +++ test/std/containers/sequences/array/array.cons/deduct.fail.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// XFAIL: libcpp-no-deduction-guides + + +// template +// array(T, U...) -> array; +// +// Requires: (is_same_v && ...) is true. Otherwise the program is ill-formed. + + +#include +#include +#include + +#include "test_macros.h" + +int main() +{ + { + std::array arr{1,2,3L}; // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'array'}} + } +} Index: test/std/containers/sequences/array/array.cons/deduct.pass.cpp =================================================================== --- test/std/containers/sequences/array/array.cons/deduct.pass.cpp +++ test/std/containers/sequences/array/array.cons/deduct.pass.cpp @@ -0,0 +1,45 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// XFAIL: libcpp-no-deduction-guides + + +// template +// array(T, U...) -> array; +// +// Requires: (is_same_v && ...) is true. Otherwise the program is ill-formed. + + +#include +#include +#include + +#include "test_macros.h" + +int main() +{ + { + std::array arr{1,2,3}; + static_assert(std::is_same_v>, ""); + assert(arr[0] == 1); + assert(arr[1] == 2); + assert(arr[2] == 3); + } + + { + std::array arr{1L, 4L, 9L, 16L}; + static_assert(std::is_same_v, ""); + static_assert(arr.size() == 4, ""); + assert(arr[0] == 1); + assert(arr[1] == 4); + assert(arr[2] == 9); + } +}