diff options
author | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-10-06 12:26:45 +0000 |
---|---|---|
committer | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-10-06 12:26:45 +0000 |
commit | 5720186d18883ddbbfcd422dd7e8638e19fd7bf3 (patch) | |
tree | ef3250caf4cb90ca1d6279b70e3e63ca6ac65e15 /libstdc++-v3 | |
parent | 542ae458063b83922178095bbbe1c2fbace2da41 (diff) | |
download | gcc-5720186d18883ddbbfcd422dd7e8638e19fd7bf3.tar.gz |
* include/Makefile.am: Add new header.
* include/Makefile.in: Regenerate.
* include/experimental/tuple: New
* doc/xml/manual/status_cxx2014.xml: Update.
* doc/html/manual/status.html: Regenerate.
* testsuite/experimental/feat-lib-fund.cc: Test for new header.
* testsuite/experimental/tuple/apply.cc: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@215930 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 10 | ||||
-rw-r--r-- | libstdc++-v3/doc/html/manual/status.html | 4 | ||||
-rw-r--r-- | libstdc++-v3/doc/xml/manual/status_cxx2014.xml | 3 | ||||
-rw-r--r-- | libstdc++-v3/include/Makefile.am | 3 | ||||
-rw-r--r-- | libstdc++-v3/include/Makefile.in | 3 | ||||
-rw-r--r-- | libstdc++-v3/include/experimental/tuple | 70 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/experimental/feat-lib-fund.cc | 4 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/experimental/tuple/apply.cc | 49 |
8 files changed, 140 insertions, 6 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 1cc81da8aae..9ebe1f7f4fe 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,13 @@ +2014-10-06 Jonathan Wakely <jwakely@redhat.com> + + * include/Makefile.am: Add new header. + * include/Makefile.in: Regenerate. + * include/experimental/tuple: New + * doc/xml/manual/status_cxx2014.xml: Update. + * doc/html/manual/status.html: Regenerate. + * testsuite/experimental/feat-lib-fund.cc: Test for new header. + * testsuite/experimental/tuple/apply.cc: New. + 2014-10-05 François Dumont <fdumont@gcc.gnu.org> PR libstdc++/63456 diff --git a/libstdc++-v3/doc/html/manual/status.html b/libstdc++-v3/doc/html/manual/status.html index e6e27f83440..a90b435b581 100644 --- a/libstdc++-v3/doc/html/manual/status.html +++ b/libstdc++-v3/doc/html/manual/status.html @@ -391,11 +391,11 @@ not in any particular release. <a class="link" href="" target="_top"> N3905 </a> - </td><td align="left">Faster string searching (Boyer-Moore et al.)</td><td align="left">N</td><td align="left">Library Fundamentals TS</td></tr><tr bgcolor="#C8B0B0"><td align="left"> + </td><td align="left">Faster string searching (Boyer-Moore et al.)</td><td align="left">N</td><td align="left">Library Fundamentals TS</td></tr><tr><td align="left"> <a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3915.pdf" target="_top"> N3915 </a> - </td><td align="left">apply() call a function with arguments from a tuple</td><td align="left">N</td><td align="left">Library Fundamentals TS</td></tr><tr bgcolor="#C8B0B0"><td align="left"> + </td><td align="left">apply() call a function with arguments from a tuple</td><td align="left">Y</td><td align="left">Library Fundamentals TS</td></tr><tr bgcolor="#C8B0B0"><td align="left"> <a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3916.pdf" target="_top"> N3916 </a> diff --git a/libstdc++-v3/doc/xml/manual/status_cxx2014.xml b/libstdc++-v3/doc/xml/manual/status_cxx2014.xml index 11254d6efc4..b7ed7ed72f6 100644 --- a/libstdc++-v3/doc/xml/manual/status_cxx2014.xml +++ b/libstdc++-v3/doc/xml/manual/status_cxx2014.xml @@ -353,14 +353,13 @@ not in any particular release. </row> <row> - <?dbhtml bgcolor="#C8B0B0" ?> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3915.pdf"> N3915 </link> </entry> <entry>apply() call a function with arguments from a tuple</entry> - <entry>N</entry> + <entry>Y</entry> <entry>Library Fundamentals TS</entry> </row> diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index 5476a378b67..dee4a3fc6f8 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -642,7 +642,8 @@ experimental_headers = \ ${experimental_srcdir}/any \ ${experimental_srcdir}/optional \ ${experimental_srcdir}/string_view \ - ${experimental_srcdir}/string_view.tcc + ${experimental_srcdir}/string_view.tcc \ + ${experimental_srcdir}/tuple # This is the common subset of C++ files that all three "C" header models use. c_base_srcdir = $(C_INCLUDE_DIR) diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index bea586ea613..83dcefbd2df 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -908,7 +908,8 @@ experimental_headers = \ ${experimental_srcdir}/any \ ${experimental_srcdir}/optional \ ${experimental_srcdir}/string_view \ - ${experimental_srcdir}/string_view.tcc + ${experimental_srcdir}/string_view.tcc \ + ${experimental_srcdir}/tuple # This is the common subset of C++ files that all three "C" header models use. diff --git a/libstdc++-v3/include/experimental/tuple b/libstdc++-v3/include/experimental/tuple new file mode 100644 index 00000000000..bbfbdfa52dc --- /dev/null +++ b/libstdc++-v3/include/experimental/tuple @@ -0,0 +1,70 @@ +// <experimental/tuple> -*- C++ -*- + +// Copyright (C) 2014 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/tuple + * This is a TS C++ Library header. + */ + +#ifndef _GLIBCXX_EXPERIMENTAL_TUPLE +#define _GLIBCXX_EXPERIMENTAL_TUPLE 1 + +#pragma GCC system_header + +#if __cplusplus <= 201103L +# include <bits/c++14_warning.h> +#else + +#include <tuple> + +namespace std _GLIBCXX_VISIBILITY(default) +{ +namespace experimental +{ +inline namespace fundamentals_v1 +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template <typename _Fn, typename _Tuple, std::size_t... _Idx> + constexpr decltype(auto) + __apply_impl(_Fn&& f, _Tuple&& t, std::index_sequence<_Idx...>) + { return std::forward<_Fn>(f)(get<_Idx>(forward<_Tuple>(t))...); } + + template <typename _Fn, typename _Tuple> + constexpr decltype(auto) + apply(_Fn&& f, _Tuple&& t) + { + using _Indices = + std::make_index_sequence<std::tuple_size<std::decay_t<_Tuple>>::value>; + return __apply_impl(std::forward<_Fn>(f), std::forward<_Tuple>(t), + _Indices{}); + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + +#endif // C++14 + +#endif // _GLIBCXX_EXPERIMENTAL_TUPLE diff --git a/libstdc++-v3/testsuite/experimental/feat-lib-fund.cc b/libstdc++-v3/testsuite/experimental/feat-lib-fund.cc index 50d1ce247f0..0c73f097a10 100644 --- a/libstdc++-v3/testsuite/experimental/feat-lib-fund.cc +++ b/libstdc++-v3/testsuite/experimental/feat-lib-fund.cc @@ -23,3 +23,7 @@ #if !__has_include(<experimental/string_view>) # error "<experimental/string_view>" #endif + +#if !__has_include(<experimental/tuple>) +# error "<experimental/tuple>" +#endif diff --git a/libstdc++-v3/testsuite/experimental/tuple/apply.cc b/libstdc++-v3/testsuite/experimental/tuple/apply.cc new file mode 100644 index 00000000000..170a8d9fad9 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/tuple/apply.cc @@ -0,0 +1,49 @@ +// Copyright (C) 2014 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 copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++14" } + +#include <experimental/tuple> +#include <testsuite_hooks.h> + +void +test01() +{ + auto t = std::make_tuple(1, '2', 3.0); + std::experimental::apply( [&](int& i, char& c, double& d) { + VERIFY(&i == &std::get<int>(t)); + VERIFY(&c == &std::get<char>(t)); + VERIFY(&d == &std::get<double>(t)); + }, t); +} + +constexpr int func(int i, int j) { return i + j; } + +void +test02() +{ + constexpr auto t = std::make_tuple(1, 2); + constexpr int i = std::experimental::apply(func, t); + VERIFY( i == 3 ); +} + +int +main() +{ + test01(); + test02(); +} |