From 5720186d18883ddbbfcd422dd7e8638e19fd7bf3 Mon Sep 17 00:00:00 2001 From: redi Date: Mon, 6 Oct 2014 12:26:45 +0000 Subject: [PATCH] * 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 --- libstdc++-v3/ChangeLog | 10 ++++ libstdc++-v3/doc/html/manual/status.html | 4 +- libstdc++-v3/doc/xml/manual/status_cxx2014.xml | 3 +- libstdc++-v3/include/Makefile.am | 3 +- libstdc++-v3/include/Makefile.in | 3 +- libstdc++-v3/include/experimental/tuple | 70 ++++++++++++++++++++++ .../testsuite/experimental/feat-lib-fund.cc | 4 ++ libstdc++-v3/testsuite/experimental/tuple/apply.cc | 49 +++++++++++++++ 8 files changed, 140 insertions(+), 6 deletions(-) create mode 100644 libstdc++-v3/include/experimental/tuple create mode 100644 libstdc++-v3/testsuite/experimental/tuple/apply.cc 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 + + * 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 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. N3905 - Faster string searching (Boyer-Moore et al.)NLibrary Fundamentals TS + Faster string searching (Boyer-Moore et al.)NLibrary Fundamentals TS N3915 - apply() call a function with arguments from a tupleNLibrary Fundamentals TS + apply() call a function with arguments from a tupleYLibrary Fundamentals TS N3916 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. - N3915 apply() call a function with arguments from a tuple - N + Y Library Fundamentals TS 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 @@ +// -*- 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 +// . + +/** @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 +#else + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +namespace experimental +{ +inline namespace fundamentals_v1 +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + constexpr decltype(auto) + __apply_impl(_Fn&& f, _Tuple&& t, std::index_sequence<_Idx...>) + { return std::forward<_Fn>(f)(get<_Idx>(forward<_Tuple>(t))...); } + + template + constexpr decltype(auto) + apply(_Fn&& f, _Tuple&& t) + { + using _Indices = + std::make_index_sequence>::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() # error "" #endif + +#if !__has_include() +# error "" +#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 +// . + +// { dg-options "-std=gnu++14" } + +#include +#include + +void +test01() +{ + auto t = std::make_tuple(1, '2', 3.0); + std::experimental::apply( [&](int& i, char& c, double& d) { + VERIFY(&i == &std::get(t)); + VERIFY(&c == &std::get(t)); + VERIFY(&d == &std::get(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(); +} -- 2.11.4.GIT