diff options
author | ville <ville@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-08-13 14:55:46 +0000 |
---|---|---|
committer | ville <ville@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-08-13 14:55:46 +0000 |
commit | 4958a58790d0c932c19a1ab4c109d2e89db441a7 (patch) | |
tree | e15a5bc2a1c2244ef0bd87e60aed7712973d6c53 /libstdc++-v3 | |
parent | a65c36dc2b3a46ea1f9ce50a01247d5efd067f35 (diff) | |
download | gcc-4958a58790d0c932c19a1ab4c109d2e89db441a7.tar.gz |
2015-08-13 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement std::experimental::fundamentals_v2::make_array and
std::experimental::fundamentals_v2::to_array.
* include/Makefile.am: Add array.
* include/Makefile.in: Add array.
* include/experimental/array: New.
* testsuite/experimental/array/make_array.cc: Likewise.
* testsuite/experimental/array/neg.cc: Likewise.
* doc/html/manual/status.html: Mark make_array as Y.
* doc/xml/manual/status_cxx2017.xml: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@226865 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 12 | ||||
-rw-r--r-- | libstdc++-v3/doc/html/manual/status.html | 4 | ||||
-rw-r--r-- | libstdc++-v3/doc/xml/manual/status_cxx2017.xml | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/Makefile.am | 1 | ||||
-rw-r--r-- | libstdc++-v3/include/Makefile.in | 1 | ||||
-rw-r--r-- | libstdc++-v3/include/experimental/array | 109 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/experimental/array/make_array.cc | 47 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/experimental/array/neg.cc | 28 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/experimental/array/neg.ii.gz | bin | 0 -> 74810 bytes | |||
-rw-r--r-- | libstdc++-v3/testsuite/experimental/array/neg.s | 1 |
10 files changed, 202 insertions, 3 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 13b83da84f7..de05109e92c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,15 @@ +2015-08-13 Ville Voutilainen <ville.voutilainen@gmail.com> + + Implement std::experimental::fundamentals_v2::make_array and + std::experimental::fundamentals_v2::to_array. + * include/Makefile.am: Add array. + * include/Makefile.in: Add array. + * include/experimental/array: New. + * testsuite/experimental/array/make_array.cc: Likewise. + * testsuite/experimental/array/neg.cc: Likewise. + * doc/html/manual/status.html: Mark make_array as Y. + * doc/xml/manual/status_cxx2017.xml: Likewise. + 2015-08-13 Jonathan Wakely <jwakely@redhat.com> * include/bits/alloc_traits.h: Add feature-test macro. diff --git a/libstdc++-v3/doc/html/manual/status.html b/libstdc++-v3/doc/html/manual/status.html index b388ff7fb2e..4ec871f1127 100644 --- a/libstdc++-v3/doc/html/manual/status.html +++ b/libstdc++-v3/doc/html/manual/status.html @@ -563,7 +563,7 @@ not in any particular release. <a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4391.html" target="_top"> N4391 </a> - </td><td align="left"> <code class="code">make_array</code>, revision 4 </td><td align="left">Y (not committed yet)</td><td align="left">Library Fundamentals 2 TS</td></tr><tr><td align="left"> + </td><td align="left"> <code class="code">make_array</code>, revision 4 </td><td align="left">Y</td><td align="left">Library Fundamentals 2 TS</td></tr><tr><td align="left"> <a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4502.pdf" target="_top"> N4502 </a> @@ -630,4 +630,4 @@ particular release. </td></tr></tbody></table></div></div><br class="table-break" /></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="intro.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="intro.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="license.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Part I. Introduction - </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> License</td></tr></table></div></body></html>
\ No newline at end of file + </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> License</td></tr></table></div></body></html> diff --git a/libstdc++-v3/doc/xml/manual/status_cxx2017.xml b/libstdc++-v3/doc/xml/manual/status_cxx2017.xml index b62536480aa..fc2ebd2466f 100644 --- a/libstdc++-v3/doc/xml/manual/status_cxx2017.xml +++ b/libstdc++-v3/doc/xml/manual/status_cxx2017.xml @@ -316,7 +316,7 @@ not in any particular release. </link> </entry> <entry> <code>make_array</code>, revision 4 </entry> - <entry>Y (not committed yet)</entry> + <entry>Y</entry> <entry>Library Fundamentals 2 TS</entry> </row> diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index c0028dd324e..41fc4af6d30 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -646,6 +646,7 @@ experimental_builddir = ./experimental experimental_headers = \ ${experimental_srcdir}/algorithm \ ${experimental_srcdir}/any \ + ${experimental_srcdir}/array \ ${experimental_srcdir}/chrono \ ${experimental_srcdir}/deque \ ${experimental_srcdir}/erase_if.h \ diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index 9539f5fe062..6470d0173d5 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -935,6 +935,7 @@ experimental_builddir = ./experimental experimental_headers = \ ${experimental_srcdir}/algorithm \ ${experimental_srcdir}/any \ + ${experimental_srcdir}/array \ ${experimental_srcdir}/chrono \ ${experimental_srcdir}/deque \ ${experimental_srcdir}/erase_if.h \ diff --git a/libstdc++-v3/include/experimental/array b/libstdc++-v3/include/experimental/array new file mode 100644 index 00000000000..a6e983aeedf --- /dev/null +++ b/libstdc++-v3/include/experimental/array @@ -0,0 +1,109 @@ +// <experimental/array> -*- C++ -*- + +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file experimental/array + * This is a TS C++ Library header. + */ + +#ifndef _GLIBCXX_EXPERIMENTAL_ARRAY +#define _GLIBCXX_EXPERIMENTAL_ARRAY 1 + +#pragma GCC system_header + +#if __cplusplus <= 201103L +# include <bits/c++14_warning.h> +#else + +#include <array> +#include <functional> +#include <experimental/type_traits> + +namespace std _GLIBCXX_VISIBILITY(default) +{ +namespace experimental +{ +inline namespace fundamentals_v2 +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup make_array Array creation functions + * @ingroup experimental + * + * Array creation functions as described in N4529, + * Working Draft, C++ Extensions for Library Fundamentals, Version 2 + * + * @{ + */ + +template <typename _Up> + struct __is_reference_wrapper : false_type + {}; + +template <typename _Up> + struct __is_reference_wrapper<reference_wrapper<_Up>> : true_type + {}; + +template <typename _Dest = void, typename... _Types> + constexpr auto + make_array(_Types&&... __t) + -> array<conditional_t<is_void_v<_Dest>, + common_type_t<_Types...>, + _Dest>, + sizeof...(_Types)> + { + static_assert(__or_< + __not_<is_void<_Dest>>, + __and_<__not_<__is_reference_wrapper<decay_t<_Types>>>...>> + ::value, + "make_array cannot be used without an explicit target type " + "if any of the types given is a reference_wrapper"); + return {{forward<_Types>(__t)...}}; + } + +template <typename _Tp, size_t _Nm, size_t... _Idx> + constexpr array<remove_cv_t<_Tp>, _Nm> + __to_array(_Tp (&__a)[_Nm], + index_sequence<_Idx...>) + { + return {{__a[_Idx]...}}; + } + +template <typename _Tp, size_t _Nm> + constexpr array<remove_cv_t<_Tp>, _Nm> + to_array(_Tp (&__a)[_Nm]) + { + return __to_array(__a, make_index_sequence<_Nm>{}); + } + + // @} group make_array + _GLIBCXX_END_NAMESPACE_VERSION +} // namespace fundamentals_v2 +} // namespace experimental + +} // namespace std + +#endif // C++14 + +#endif // _GLIBCXX_EXPERIMENTAL_ARRAY diff --git a/libstdc++-v3/testsuite/experimental/array/make_array.cc b/libstdc++-v3/testsuite/experimental/array/make_array.cc new file mode 100644 index 00000000000..772ef466ab9 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/array/make_array.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++14" } +// { dg-do compile } + +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a moved_to of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <experimental/array> + +struct MoveOnly +{ + MoveOnly() = default; + MoveOnly(MoveOnly&&) = default; + MoveOnly& operator=(MoveOnly&&) = default; +}; + +int main() +{ + char x[42]; + std::array<char, 42> y = std::experimental::to_array(x); + std::array<int, 5> z = std::experimental::make_array(1,2,3,4,5); + std::array<long, 3> zz = std::experimental::make_array(1,2L, 3); + std::array<MoveOnly, 1> zzz = std::experimental::make_array(MoveOnly{}); + int dummy; + auto good = std::experimental::make_array< + std::reference_wrapper<int>>(std::ref(dummy)); + constexpr char x2[42]{}; + constexpr std::array<char, 42> y2 = std::experimental::to_array(x2); + constexpr std::array<int, 5> z2 = + std::experimental::make_array(1,2,3,4,5); + constexpr std::array<long, 3> zz2 + = std::experimental::make_array(1,2L, 3); + constexpr std::array<MoveOnly, 1> zzz2 = std::experimental::make_array(MoveOnly{}); +} diff --git a/libstdc++-v3/testsuite/experimental/array/neg.cc b/libstdc++-v3/testsuite/experimental/array/neg.cc new file mode 100644 index 00000000000..df532d166c5 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/array/neg.cc @@ -0,0 +1,28 @@ +// { dg-options "-std=gnu++14" } +// { dg-do compile } + +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a moved_to of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <experimental/array> + +int main() +{ + int dummy; + auto bad = std::experimental::make_array(std::ref(dummy)); + // { dg-error "make_array cannot be used without an explicit target type if any of the types given is a reference_wrapper" "" { target *-*-* } 76 } +} diff --git a/libstdc++-v3/testsuite/experimental/array/neg.ii.gz b/libstdc++-v3/testsuite/experimental/array/neg.ii.gz Binary files differnew file mode 100644 index 00000000000..8773316ce75 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/array/neg.ii.gz diff --git a/libstdc++-v3/testsuite/experimental/array/neg.s b/libstdc++-v3/testsuite/experimental/array/neg.s new file mode 100644 index 00000000000..e22209f5fe7 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/array/neg.s @@ -0,0 +1 @@ + .file "neg.cc" |