public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [libstdc++ PATCH] More Fundamentals v1 variable templates
@ 2014-10-18 20:23 Ville Voutilainen
  2014-10-18 21:07 ` Ville Voutilainen
  0 siblings, 1 reply; 5+ messages in thread
From: Ville Voutilainen @ 2014-10-18 20:23 UTC (permalink / raw)
  To: gcc-patches, libstdc++

[-- Attachment #1: Type: text/plain, Size: 657 bytes --]

Tested on Linux-x64.

2014-10-18  Ville Voutilainen  <ville.voutilainen@gmail.com>

    Implement more Library Fundamentals v1 variable templates for
    type traits.
    * include/Makefile.am: Add ratio, chrono and system_error.
    * include/experimental/chrono: New.
    * include/experimental/ratio: Likewise.
    * include/experimental/system_error: Likewise.
    * include/experimental/tuple (tuple_size_v): Likewise.
    * testsuite/experimental/chrono/value.cc: Likewise.
    * testsuite/experimental/ratio/value.cc: Likewise.
    * testsuite/experimental/system_error/value.cc: Likewise.
    * testsuite/experimental/tuple/tuple_size.cc: Likewise.

[-- Attachment #2: fundamentals-more-traits.diff --]
[-- Type: text/plain, Size: 15783 bytes --]

diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index 1ee8ddc..c797246 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -644,7 +644,10 @@ experimental_headers = \
 	${experimental_srcdir}/string_view \
 	${experimental_srcdir}/string_view.tcc \
 	${experimental_srcdir}/tuple \
-	${experimental_srcdir}/type_traits
+	${experimental_srcdir}/type_traits \
+	${experimental_srcdir}/ratio \
+	${experimental_srcdir}/chrono \
+	${experimental_srcdir}/system_error \
 
 # 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/experimental/chrono b/libstdc++-v3/include/experimental/chrono
new file mode 100644
index 0000000..d817f45
--- /dev/null
+++ b/libstdc++-v3/include/experimental/chrono
@@ -0,0 +1,65 @@
+// Variable Templates For chrono -*- 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/chrono
+ *  This is a TS C++ Library header.
+ */
+
+//
+// N3932 Variable Templates For Type Traits (Revision 1)
+//
+
+#ifndef _GLIBCXX_EXPERIMENTAL_CHRONO
+#define _GLIBCXX_EXPERIMENTAL_CHRONO 1
+
+#pragma GCC system_header
+
+#if __cplusplus <= 201103L
+# include <bits/c++14_warning.h>
+#else
+
+#include <chrono>
+
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace chrono {
+namespace experimental
+{
+inline namespace fundamentals_v1
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+// See C++14 §20.12.4, customization traits
+template <class _Rep>
+   constexpr bool treat_as_floating_point_v =
+     treat_as_floating_point<_Rep>::value;
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace chrono
+} // namespace std
+
+#endif // __cplusplus <= 201103L
+
+#endif // _GLIBCXX_EXPERIMENTAL_CHRONO
diff --git a/libstdc++-v3/include/experimental/ratio b/libstdc++-v3/include/experimental/ratio
new file mode 100644
index 0000000..dbbe33f
--- /dev/null
+++ b/libstdc++-v3/include/experimental/ratio
@@ -0,0 +1,73 @@
+// Variable Templates For ratio -*- 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/ratio
+ *  This is a TS C++ Library header.
+ */
+
+//
+// N3932 Variable Templates For Type Traits (Revision 1)
+//
+
+#ifndef _GLIBCXX_EXPERIMENTAL_RATIO
+#define _GLIBCXX_EXPERIMENTAL_RATIO 1
+
+#pragma GCC system_header
+
+#if __cplusplus <= 201103L
+# include <bits/c++14_warning.h>
+#else
+
+#include <ratio>
+
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace fundamentals_v1
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+// See C++14 §20.11.5, ratio comparison
+template <class _R1, class _R2>
+  constexpr bool ratio_equal_v = ratio_equal<_R1, _R2>::value;
+template <class _R1, class _R2>
+  constexpr bool ratio_not_equal_v = ratio_not_equal<_R1, _R2>::value;
+template <class _R1, class _R2>
+  constexpr bool ratio_less_v = ratio_less<_R1, _R2>::value;
+template <class _R1, class _R2>
+  constexpr bool ratio_less_equal_v = ratio_less_equal<_R1, _R2>::value;
+template <class _R1, class _R2>
+  constexpr bool ratio_greater_v = ratio_greater<_R1, _R2>::value;
+template <class _R1, class _R2>
+  constexpr bool ratio_greater_equal_v = ratio_greater_equal<_R1, _R2>::value;
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace std
+
+#endif // __cplusplus <= 201103L
+
+#endif // _GLIBCXX_EXPERIMENTAL_RATIO
diff --git a/libstdc++-v3/include/experimental/system_error b/libstdc++-v3/include/experimental/system_error
new file mode 100644
index 0000000..102a4ea
--- /dev/null
+++ b/libstdc++-v3/include/experimental/system_error
@@ -0,0 +1,64 @@
+// Variable Templates For system_error -*- 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/system_error
+ *  This is a TS C++ Library header.
+ */
+
+//
+// N3932 Variable Templates For Type Traits (Revision 1)
+//
+
+#ifndef _GLIBCXX_EXPERIMENTAL_SYSTEM_ERROR
+#define _GLIBCXX_EXPERIMENTAL_CHRONO 1
+
+#pragma GCC system_header
+
+#if __cplusplus <= 201103L
+# include <bits/c++14_warning.h>
+#else
+
+#include <system_error>
+
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace fundamentals_v1
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+// See C++14 §19.5, System error support
+template <class T>
+  constexpr bool is_error_code_enum_v = is_error_code_enum<T>::value;
+template <class T>
+  constexpr bool is_error_condition_enum_v = is_error_condition_enum<T>::value;
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace std
+
+#endif // __cplusplus <= 201103L
+
+#endif // _GLIBCXX_EXPERIMENTAL_SYSTEM_ERROR
diff --git a/libstdc++-v3/include/experimental/tuple b/libstdc++-v3/include/experimental/tuple
index bbfbdfa..5794e91 100644
--- a/libstdc++-v3/include/experimental/tuple
+++ b/libstdc++-v3/include/experimental/tuple
@@ -44,6 +44,9 @@ namespace experimental
 inline namespace fundamentals_v1
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
+  // See C++14 §20.4.2.5, tuple helper classes
+  template <class _Tp>
+    constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
 
   template <typename _Fn, typename _Tuple, std::size_t... _Idx>
     constexpr decltype(auto)
diff --git a/libstdc++-v3/testsuite/experimental/chrono/value.cc b/libstdc++-v3/testsuite/experimental/chrono/value.cc
new file mode 100644
index 0000000..c06c12a
--- /dev/null
+++ b/libstdc++-v3/testsuite/experimental/chrono/value.cc
@@ -0,0 +1,34 @@
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// 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 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/chrono>
+
+using namespace std::chrono;
+using namespace std::chrono::experimental;
+
+// These tests are rather simple, the front-end tests already test
+// variable templates, and the library tests for the underlying
+// traits are more elaborate. These are just simple sanity tests.
+
+static_assert(!treat_as_floating_point_v<int>
+	      && !treat_as_floating_point<int>::value, "");
+
+static_assert(treat_as_floating_point_v<double>
+	      && treat_as_floating_point<double>::value, "");
diff --git a/libstdc++-v3/testsuite/experimental/ratio/value.cc b/libstdc++-v3/testsuite/experimental/ratio/value.cc
new file mode 100644
index 0000000..4c8bdd7
--- /dev/null
+++ b/libstdc++-v3/testsuite/experimental/ratio/value.cc
@@ -0,0 +1,50 @@
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// 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 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/ratio>
+
+using namespace std;
+using namespace std::experimental;
+
+// These tests are rather simple, the front-end tests already test
+// variable templates, and the library tests for the underlying
+// traits are more elaborate. These are just simple sanity tests.
+
+static_assert(ratio_equal_v<ratio<1, 3>, ratio<2, 6>>
+	      && ratio_equal<ratio<1, 3>, ratio<2, 6>>::value, "");
+
+static_assert(ratio_not_equal_v<ratio<1, 3>, ratio<2, 5>>
+	      && ratio_not_equal<ratio<1, 3>, ratio<2, 5>>::value, "");
+
+static_assert(ratio_less_v<ratio<1, 4>, ratio<1, 3>>
+	      && ratio_less<ratio<1, 4>, ratio<1, 3>>::value, "");
+
+static_assert(ratio_less_equal_v<ratio<1, 4>, ratio<1, 4>>
+	      && ratio_less_equal_v<ratio<1, 4>, ratio<1, 3>>
+	      && ratio_less_equal<ratio<1, 4>, ratio<1, 4>>::value
+	      && ratio_less_equal<ratio<1, 4>, ratio<1, 3>>::value, "");
+
+static_assert(ratio_greater_v<ratio<1, 3>, ratio<1, 4>>
+	      && ratio_greater<ratio<1, 3>, ratio<1, 4>>::value, "");
+
+static_assert(ratio_greater_equal_v<ratio<1, 4>, ratio<1, 4>>
+	      && ratio_greater_equal_v<ratio<1, 3>, ratio<1, 4>>
+	      && ratio_greater_equal<ratio<1, 4>, ratio<1, 4>>::value
+	      && ratio_greater_equal<ratio<1, 3>, ratio<1, 4>>::value, "");
diff --git a/libstdc++-v3/testsuite/experimental/system_error/value.cc b/libstdc++-v3/testsuite/experimental/system_error/value.cc
new file mode 100644
index 0000000..66b40fb
--- /dev/null
+++ b/libstdc++-v3/testsuite/experimental/system_error/value.cc
@@ -0,0 +1,40 @@
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// 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 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/system_error>
+#include <future>
+using namespace std;
+using namespace std::experimental;
+
+// These tests are rather simple, the front-end tests already test
+// variable templates, and the library tests for the underlying
+// traits are more elaborate. These are just simple sanity tests.
+
+static_assert(is_error_code_enum_v<future_errc>
+	      && is_error_code_enum<future_errc>::value, "");
+
+static_assert(!is_error_code_enum_v<int>
+	      && !is_error_code_enum<int>::value, "");
+
+static_assert(is_error_condition_enum_v<errc>
+	      && is_error_condition_enum<errc>::value, "");
+
+static_assert(!is_error_condition_enum_v<int>
+	      && !is_error_condition_enum<int>::value, "");
diff --git a/libstdc++-v3/testsuite/experimental/tuple/tuple_size.cc b/libstdc++-v3/testsuite/experimental/tuple/tuple_size.cc
new file mode 100644
index 0000000..604e2c9
--- /dev/null
+++ b/libstdc++-v3/testsuite/experimental/tuple/tuple_size.cc
@@ -0,0 +1,34 @@
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// 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 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/tuple>
+
+using namespace std;
+using namespace std::experimental;
+
+// These tests are rather simple, the front-end tests already test
+// variable templates, and the library tests for the underlying
+// traits are more elaborate. These are just simple sanity tests.
+
+static_assert(tuple_size_v<tuple<int>> == 1
+	      && tuple_size<tuple<int>>::value == 1, "");
+
+static_assert(tuple_size_v<tuple<int, int>> == 2
+	      && tuple_size<tuple<int, int>>::value == 2, "");

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [libstdc++ PATCH] More Fundamentals v1 variable templates
  2014-10-18 20:23 [libstdc++ PATCH] More Fundamentals v1 variable templates Ville Voutilainen
@ 2014-10-18 21:07 ` Ville Voutilainen
  2014-10-20 12:43   ` Jonathan Wakely
  0 siblings, 1 reply; 5+ messages in thread
From: Ville Voutilainen @ 2014-10-18 21:07 UTC (permalink / raw)
  To: gcc-patches, libstdc++

[-- Attachment #1: Type: text/plain, Size: 823 bytes --]

On 18 October 2014 23:18, Ville Voutilainen <ville.voutilainen@gmail.com> wrote:
> Tested on Linux-x64.
>
> 2014-10-18  Ville Voutilainen  <ville.voutilainen@gmail.com>
>
>     Implement more Library Fundamentals v1 variable templates for
>     type traits.
>     * include/Makefile.am: Add ratio, chrono and system_error.
>     * include/experimental/chrono: New.
>     * include/experimental/ratio: Likewise.
>     * include/experimental/system_error: Likewise.
>     * include/experimental/tuple (tuple_size_v): Likewise.
>     * testsuite/experimental/chrono/value.cc: Likewise.
>     * testsuite/experimental/ratio/value.cc: Likewise.
>     * testsuite/experimental/system_error/value.cc: Likewise.
>     * testsuite/experimental/tuple/tuple_size.cc: Likewise.

Hah, failed to uglify system_error. New patch attached.

[-- Attachment #2: fundamentals-more-traits2.diff --]
[-- Type: text/plain, Size: 15797 bytes --]

diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index 1ee8ddc..c797246 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -644,7 +644,10 @@ experimental_headers = \
 	${experimental_srcdir}/string_view \
 	${experimental_srcdir}/string_view.tcc \
 	${experimental_srcdir}/tuple \
-	${experimental_srcdir}/type_traits
+	${experimental_srcdir}/type_traits \
+	${experimental_srcdir}/ratio \
+	${experimental_srcdir}/chrono \
+	${experimental_srcdir}/system_error \
 
 # 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/experimental/chrono b/libstdc++-v3/include/experimental/chrono
new file mode 100644
index 0000000..d817f45
--- /dev/null
+++ b/libstdc++-v3/include/experimental/chrono
@@ -0,0 +1,65 @@
+// Variable Templates For chrono -*- 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/chrono
+ *  This is a TS C++ Library header.
+ */
+
+//
+// N3932 Variable Templates For Type Traits (Revision 1)
+//
+
+#ifndef _GLIBCXX_EXPERIMENTAL_CHRONO
+#define _GLIBCXX_EXPERIMENTAL_CHRONO 1
+
+#pragma GCC system_header
+
+#if __cplusplus <= 201103L
+# include <bits/c++14_warning.h>
+#else
+
+#include <chrono>
+
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace chrono {
+namespace experimental
+{
+inline namespace fundamentals_v1
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+// See C++14 §20.12.4, customization traits
+template <class _Rep>
+   constexpr bool treat_as_floating_point_v =
+     treat_as_floating_point<_Rep>::value;
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace chrono
+} // namespace std
+
+#endif // __cplusplus <= 201103L
+
+#endif // _GLIBCXX_EXPERIMENTAL_CHRONO
diff --git a/libstdc++-v3/include/experimental/ratio b/libstdc++-v3/include/experimental/ratio
new file mode 100644
index 0000000..dbbe33f
--- /dev/null
+++ b/libstdc++-v3/include/experimental/ratio
@@ -0,0 +1,73 @@
+// Variable Templates For ratio -*- 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/ratio
+ *  This is a TS C++ Library header.
+ */
+
+//
+// N3932 Variable Templates For Type Traits (Revision 1)
+//
+
+#ifndef _GLIBCXX_EXPERIMENTAL_RATIO
+#define _GLIBCXX_EXPERIMENTAL_RATIO 1
+
+#pragma GCC system_header
+
+#if __cplusplus <= 201103L
+# include <bits/c++14_warning.h>
+#else
+
+#include <ratio>
+
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace fundamentals_v1
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+// See C++14 §20.11.5, ratio comparison
+template <class _R1, class _R2>
+  constexpr bool ratio_equal_v = ratio_equal<_R1, _R2>::value;
+template <class _R1, class _R2>
+  constexpr bool ratio_not_equal_v = ratio_not_equal<_R1, _R2>::value;
+template <class _R1, class _R2>
+  constexpr bool ratio_less_v = ratio_less<_R1, _R2>::value;
+template <class _R1, class _R2>
+  constexpr bool ratio_less_equal_v = ratio_less_equal<_R1, _R2>::value;
+template <class _R1, class _R2>
+  constexpr bool ratio_greater_v = ratio_greater<_R1, _R2>::value;
+template <class _R1, class _R2>
+  constexpr bool ratio_greater_equal_v = ratio_greater_equal<_R1, _R2>::value;
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace std
+
+#endif // __cplusplus <= 201103L
+
+#endif // _GLIBCXX_EXPERIMENTAL_RATIO
diff --git a/libstdc++-v3/include/experimental/system_error b/libstdc++-v3/include/experimental/system_error
new file mode 100644
index 0000000..50a5e72
--- /dev/null
+++ b/libstdc++-v3/include/experimental/system_error
@@ -0,0 +1,65 @@
+// Variable Templates For system_error -*- 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/system_error
+ *  This is a TS C++ Library header.
+ */
+
+//
+// N3932 Variable Templates For Type Traits (Revision 1)
+//
+
+#ifndef _GLIBCXX_EXPERIMENTAL_SYSTEM_ERROR
+#define _GLIBCXX_EXPERIMENTAL_CHRONO 1
+
+#pragma GCC system_header
+
+#if __cplusplus <= 201103L
+# include <bits/c++14_warning.h>
+#else
+
+#include <system_error>
+
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace fundamentals_v1
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+// See C++14 §19.5, System error support
+template <class _Tp>
+  constexpr bool is_error_code_enum_v = is_error_code_enum<_Tp>::value;
+template <class _Tp>
+  constexpr bool is_error_condition_enum_v = 
+    is_error_condition_enum<_Tp>::value;
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace std
+
+#endif // __cplusplus <= 201103L
+
+#endif // _GLIBCXX_EXPERIMENTAL_SYSTEM_ERROR
diff --git a/libstdc++-v3/include/experimental/tuple b/libstdc++-v3/include/experimental/tuple
index bbfbdfa..5794e91 100644
--- a/libstdc++-v3/include/experimental/tuple
+++ b/libstdc++-v3/include/experimental/tuple
@@ -44,6 +44,9 @@ namespace experimental
 inline namespace fundamentals_v1
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
+  // See C++14 §20.4.2.5, tuple helper classes
+  template <class _Tp>
+    constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
 
   template <typename _Fn, typename _Tuple, std::size_t... _Idx>
     constexpr decltype(auto)
diff --git a/libstdc++-v3/testsuite/experimental/chrono/value.cc b/libstdc++-v3/testsuite/experimental/chrono/value.cc
new file mode 100644
index 0000000..c06c12a
--- /dev/null
+++ b/libstdc++-v3/testsuite/experimental/chrono/value.cc
@@ -0,0 +1,34 @@
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// 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 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/chrono>
+
+using namespace std::chrono;
+using namespace std::chrono::experimental;
+
+// These tests are rather simple, the front-end tests already test
+// variable templates, and the library tests for the underlying
+// traits are more elaborate. These are just simple sanity tests.
+
+static_assert(!treat_as_floating_point_v<int>
+	      && !treat_as_floating_point<int>::value, "");
+
+static_assert(treat_as_floating_point_v<double>
+	      && treat_as_floating_point<double>::value, "");
diff --git a/libstdc++-v3/testsuite/experimental/ratio/value.cc b/libstdc++-v3/testsuite/experimental/ratio/value.cc
new file mode 100644
index 0000000..4c8bdd7
--- /dev/null
+++ b/libstdc++-v3/testsuite/experimental/ratio/value.cc
@@ -0,0 +1,50 @@
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// 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 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/ratio>
+
+using namespace std;
+using namespace std::experimental;
+
+// These tests are rather simple, the front-end tests already test
+// variable templates, and the library tests for the underlying
+// traits are more elaborate. These are just simple sanity tests.
+
+static_assert(ratio_equal_v<ratio<1, 3>, ratio<2, 6>>
+	      && ratio_equal<ratio<1, 3>, ratio<2, 6>>::value, "");
+
+static_assert(ratio_not_equal_v<ratio<1, 3>, ratio<2, 5>>
+	      && ratio_not_equal<ratio<1, 3>, ratio<2, 5>>::value, "");
+
+static_assert(ratio_less_v<ratio<1, 4>, ratio<1, 3>>
+	      && ratio_less<ratio<1, 4>, ratio<1, 3>>::value, "");
+
+static_assert(ratio_less_equal_v<ratio<1, 4>, ratio<1, 4>>
+	      && ratio_less_equal_v<ratio<1, 4>, ratio<1, 3>>
+	      && ratio_less_equal<ratio<1, 4>, ratio<1, 4>>::value
+	      && ratio_less_equal<ratio<1, 4>, ratio<1, 3>>::value, "");
+
+static_assert(ratio_greater_v<ratio<1, 3>, ratio<1, 4>>
+	      && ratio_greater<ratio<1, 3>, ratio<1, 4>>::value, "");
+
+static_assert(ratio_greater_equal_v<ratio<1, 4>, ratio<1, 4>>
+	      && ratio_greater_equal_v<ratio<1, 3>, ratio<1, 4>>
+	      && ratio_greater_equal<ratio<1, 4>, ratio<1, 4>>::value
+	      && ratio_greater_equal<ratio<1, 3>, ratio<1, 4>>::value, "");
diff --git a/libstdc++-v3/testsuite/experimental/system_error/value.cc b/libstdc++-v3/testsuite/experimental/system_error/value.cc
new file mode 100644
index 0000000..66b40fb
--- /dev/null
+++ b/libstdc++-v3/testsuite/experimental/system_error/value.cc
@@ -0,0 +1,40 @@
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// 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 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/system_error>
+#include <future>
+using namespace std;
+using namespace std::experimental;
+
+// These tests are rather simple, the front-end tests already test
+// variable templates, and the library tests for the underlying
+// traits are more elaborate. These are just simple sanity tests.
+
+static_assert(is_error_code_enum_v<future_errc>
+	      && is_error_code_enum<future_errc>::value, "");
+
+static_assert(!is_error_code_enum_v<int>
+	      && !is_error_code_enum<int>::value, "");
+
+static_assert(is_error_condition_enum_v<errc>
+	      && is_error_condition_enum<errc>::value, "");
+
+static_assert(!is_error_condition_enum_v<int>
+	      && !is_error_condition_enum<int>::value, "");
diff --git a/libstdc++-v3/testsuite/experimental/tuple/tuple_size.cc b/libstdc++-v3/testsuite/experimental/tuple/tuple_size.cc
new file mode 100644
index 0000000..604e2c9
--- /dev/null
+++ b/libstdc++-v3/testsuite/experimental/tuple/tuple_size.cc
@@ -0,0 +1,34 @@
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// 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 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/tuple>
+
+using namespace std;
+using namespace std::experimental;
+
+// These tests are rather simple, the front-end tests already test
+// variable templates, and the library tests for the underlying
+// traits are more elaborate. These are just simple sanity tests.
+
+static_assert(tuple_size_v<tuple<int>> == 1
+	      && tuple_size<tuple<int>>::value == 1, "");
+
+static_assert(tuple_size_v<tuple<int, int>> == 2
+	      && tuple_size<tuple<int, int>>::value == 2, "");

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [libstdc++ PATCH] More Fundamentals v1 variable templates
  2014-10-18 21:07 ` Ville Voutilainen
@ 2014-10-20 12:43   ` Jonathan Wakely
  2014-10-21  5:37     ` Ville Voutilainen
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Wakely @ 2014-10-20 12:43 UTC (permalink / raw)
  To: Ville Voutilainen; +Cc: gcc-patches, libstdc++

On 18/10/14 23:22 +0300, Ville Voutilainen wrote:
>On 18 October 2014 23:18, Ville Voutilainen <ville.voutilainen@gmail.com> wrote:
>> Tested on Linux-x64.
>>
>> 2014-10-18  Ville Voutilainen  <ville.voutilainen@gmail.com>
>>
>>     Implement more Library Fundamentals v1 variable templates for
>>     type traits.
>>     * include/Makefile.am: Add ratio, chrono and system_error.
>>     * include/experimental/chrono: New.
>>     * include/experimental/ratio: Likewise.
>>     * include/experimental/system_error: Likewise.
>>     * include/experimental/tuple (tuple_size_v): Likewise.
>>     * testsuite/experimental/chrono/value.cc: Likewise.
>>     * testsuite/experimental/ratio/value.cc: Likewise.
>>     * testsuite/experimental/system_error/value.cc: Likewise.
>>     * testsuite/experimental/tuple/tuple_size.cc: Likewise.
>
>Hah, failed to uglify system_error. New patch attached.

Thanks.

The templates should also use 'typename' not 'class' but I can make
that change before committing it so no need for a new patch.

I'll do the commit tomorrow.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [libstdc++ PATCH] More Fundamentals v1 variable templates
  2014-10-20 12:43   ` Jonathan Wakely
@ 2014-10-21  5:37     ` Ville Voutilainen
  2014-10-21 13:21       ` Jonathan Wakely
  0 siblings, 1 reply; 5+ messages in thread
From: Ville Voutilainen @ 2014-10-21  5:37 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: gcc-patches, libstdc++

[-- Attachment #1: Type: text/plain, Size: 308 bytes --]

On 20 October 2014 15:38, Jonathan Wakely <jwakely@redhat.com> wrote:
> The templates should also use 'typename' not 'class' but I can make
> that change before committing it so no need for a new patch.


No, no, no! Contributors must be punished, otherwise they will never learn! ;)
Revised patch attached.

[-- Attachment #2: fundamentals-more-traits3.diff --]
[-- Type: text/plain, Size: 15845 bytes --]

diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index 1ee8ddc..c797246 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -644,7 +644,10 @@ experimental_headers = \
 	${experimental_srcdir}/string_view \
 	${experimental_srcdir}/string_view.tcc \
 	${experimental_srcdir}/tuple \
-	${experimental_srcdir}/type_traits
+	${experimental_srcdir}/type_traits \
+	${experimental_srcdir}/ratio \
+	${experimental_srcdir}/chrono \
+	${experimental_srcdir}/system_error \
 
 # 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/experimental/chrono b/libstdc++-v3/include/experimental/chrono
new file mode 100644
index 0000000..4754ea0
--- /dev/null
+++ b/libstdc++-v3/include/experimental/chrono
@@ -0,0 +1,65 @@
+// Variable Templates For chrono -*- 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/chrono
+ *  This is a TS C++ Library header.
+ */
+
+//
+// N3932 Variable Templates For Type Traits (Revision 1)
+//
+
+#ifndef _GLIBCXX_EXPERIMENTAL_CHRONO
+#define _GLIBCXX_EXPERIMENTAL_CHRONO 1
+
+#pragma GCC system_header
+
+#if __cplusplus <= 201103L
+# include <bits/c++14_warning.h>
+#else
+
+#include <chrono>
+
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace chrono {
+namespace experimental
+{
+inline namespace fundamentals_v1
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+// See C++14 §20.12.4, customization traits
+template <typename _Rep>
+   constexpr bool treat_as_floating_point_v =
+     treat_as_floating_point<_Rep>::value;
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace chrono
+} // namespace std
+
+#endif // __cplusplus <= 201103L
+
+#endif // _GLIBCXX_EXPERIMENTAL_CHRONO
diff --git a/libstdc++-v3/include/experimental/ratio b/libstdc++-v3/include/experimental/ratio
new file mode 100644
index 0000000..1f2080b
--- /dev/null
+++ b/libstdc++-v3/include/experimental/ratio
@@ -0,0 +1,73 @@
+// Variable Templates For ratio -*- 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/ratio
+ *  This is a TS C++ Library header.
+ */
+
+//
+// N3932 Variable Templates For Type Traits (Revision 1)
+//
+
+#ifndef _GLIBCXX_EXPERIMENTAL_RATIO
+#define _GLIBCXX_EXPERIMENTAL_RATIO 1
+
+#pragma GCC system_header
+
+#if __cplusplus <= 201103L
+# include <bits/c++14_warning.h>
+#else
+
+#include <ratio>
+
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace fundamentals_v1
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+// See C++14 §20.11.5, ratio comparison
+template <typename _R1, typename _R2>
+  constexpr bool ratio_equal_v = ratio_equal<_R1, _R2>::value;
+template <typename _R1, typename _R2>
+  constexpr bool ratio_not_equal_v = ratio_not_equal<_R1, _R2>::value;
+template <typename _R1, typename _R2>
+  constexpr bool ratio_less_v = ratio_less<_R1, _R2>::value;
+template <typename _R1, typename _R2>
+  constexpr bool ratio_less_equal_v = ratio_less_equal<_R1, _R2>::value;
+template <typename _R1, typename _R2>
+  constexpr bool ratio_greater_v = ratio_greater<_R1, _R2>::value;
+template <typename _R1, typename _R2>
+  constexpr bool ratio_greater_equal_v = ratio_greater_equal<_R1, _R2>::value;
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace std
+
+#endif // __cplusplus <= 201103L
+
+#endif // _GLIBCXX_EXPERIMENTAL_RATIO
diff --git a/libstdc++-v3/include/experimental/system_error b/libstdc++-v3/include/experimental/system_error
new file mode 100644
index 0000000..683021f
--- /dev/null
+++ b/libstdc++-v3/include/experimental/system_error
@@ -0,0 +1,65 @@
+// Variable Templates For system_error -*- 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/system_error
+ *  This is a TS C++ Library header.
+ */
+
+//
+// N3932 Variable Templates For Type Traits (Revision 1)
+//
+
+#ifndef _GLIBCXX_EXPERIMENTAL_SYSTEM_ERROR
+#define _GLIBCXX_EXPERIMENTAL_CHRONO 1
+
+#pragma GCC system_header
+
+#if __cplusplus <= 201103L
+# include <bits/c++14_warning.h>
+#else
+
+#include <system_error>
+
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace fundamentals_v1
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+// See C++14 §19.5, System error support
+template <typename _Tp>
+  constexpr bool is_error_code_enum_v = is_error_code_enum<_Tp>::value;
+template <typename _Tp>
+  constexpr bool is_error_condition_enum_v = 
+    is_error_condition_enum<_Tp>::value;
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace std
+
+#endif // __cplusplus <= 201103L
+
+#endif // _GLIBCXX_EXPERIMENTAL_SYSTEM_ERROR
diff --git a/libstdc++-v3/include/experimental/tuple b/libstdc++-v3/include/experimental/tuple
index bbfbdfa..da756b8 100644
--- a/libstdc++-v3/include/experimental/tuple
+++ b/libstdc++-v3/include/experimental/tuple
@@ -44,6 +44,9 @@ namespace experimental
 inline namespace fundamentals_v1
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
+  // See C++14 §20.4.2.5, tuple helper classes
+  template <typename _Tp>
+    constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
 
   template <typename _Fn, typename _Tuple, std::size_t... _Idx>
     constexpr decltype(auto)
diff --git a/libstdc++-v3/testsuite/experimental/chrono/value.cc b/libstdc++-v3/testsuite/experimental/chrono/value.cc
new file mode 100644
index 0000000..c06c12a
--- /dev/null
+++ b/libstdc++-v3/testsuite/experimental/chrono/value.cc
@@ -0,0 +1,34 @@
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// 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 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/chrono>
+
+using namespace std::chrono;
+using namespace std::chrono::experimental;
+
+// These tests are rather simple, the front-end tests already test
+// variable templates, and the library tests for the underlying
+// traits are more elaborate. These are just simple sanity tests.
+
+static_assert(!treat_as_floating_point_v<int>
+	      && !treat_as_floating_point<int>::value, "");
+
+static_assert(treat_as_floating_point_v<double>
+	      && treat_as_floating_point<double>::value, "");
diff --git a/libstdc++-v3/testsuite/experimental/ratio/value.cc b/libstdc++-v3/testsuite/experimental/ratio/value.cc
new file mode 100644
index 0000000..4c8bdd7
--- /dev/null
+++ b/libstdc++-v3/testsuite/experimental/ratio/value.cc
@@ -0,0 +1,50 @@
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// 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 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/ratio>
+
+using namespace std;
+using namespace std::experimental;
+
+// These tests are rather simple, the front-end tests already test
+// variable templates, and the library tests for the underlying
+// traits are more elaborate. These are just simple sanity tests.
+
+static_assert(ratio_equal_v<ratio<1, 3>, ratio<2, 6>>
+	      && ratio_equal<ratio<1, 3>, ratio<2, 6>>::value, "");
+
+static_assert(ratio_not_equal_v<ratio<1, 3>, ratio<2, 5>>
+	      && ratio_not_equal<ratio<1, 3>, ratio<2, 5>>::value, "");
+
+static_assert(ratio_less_v<ratio<1, 4>, ratio<1, 3>>
+	      && ratio_less<ratio<1, 4>, ratio<1, 3>>::value, "");
+
+static_assert(ratio_less_equal_v<ratio<1, 4>, ratio<1, 4>>
+	      && ratio_less_equal_v<ratio<1, 4>, ratio<1, 3>>
+	      && ratio_less_equal<ratio<1, 4>, ratio<1, 4>>::value
+	      && ratio_less_equal<ratio<1, 4>, ratio<1, 3>>::value, "");
+
+static_assert(ratio_greater_v<ratio<1, 3>, ratio<1, 4>>
+	      && ratio_greater<ratio<1, 3>, ratio<1, 4>>::value, "");
+
+static_assert(ratio_greater_equal_v<ratio<1, 4>, ratio<1, 4>>
+	      && ratio_greater_equal_v<ratio<1, 3>, ratio<1, 4>>
+	      && ratio_greater_equal<ratio<1, 4>, ratio<1, 4>>::value
+	      && ratio_greater_equal<ratio<1, 3>, ratio<1, 4>>::value, "");
diff --git a/libstdc++-v3/testsuite/experimental/system_error/value.cc b/libstdc++-v3/testsuite/experimental/system_error/value.cc
new file mode 100644
index 0000000..66b40fb
--- /dev/null
+++ b/libstdc++-v3/testsuite/experimental/system_error/value.cc
@@ -0,0 +1,40 @@
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// 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 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/system_error>
+#include <future>
+using namespace std;
+using namespace std::experimental;
+
+// These tests are rather simple, the front-end tests already test
+// variable templates, and the library tests for the underlying
+// traits are more elaborate. These are just simple sanity tests.
+
+static_assert(is_error_code_enum_v<future_errc>
+	      && is_error_code_enum<future_errc>::value, "");
+
+static_assert(!is_error_code_enum_v<int>
+	      && !is_error_code_enum<int>::value, "");
+
+static_assert(is_error_condition_enum_v<errc>
+	      && is_error_condition_enum<errc>::value, "");
+
+static_assert(!is_error_condition_enum_v<int>
+	      && !is_error_condition_enum<int>::value, "");
diff --git a/libstdc++-v3/testsuite/experimental/tuple/tuple_size.cc b/libstdc++-v3/testsuite/experimental/tuple/tuple_size.cc
new file mode 100644
index 0000000..604e2c9
--- /dev/null
+++ b/libstdc++-v3/testsuite/experimental/tuple/tuple_size.cc
@@ -0,0 +1,34 @@
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// 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 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/tuple>
+
+using namespace std;
+using namespace std::experimental;
+
+// These tests are rather simple, the front-end tests already test
+// variable templates, and the library tests for the underlying
+// traits are more elaborate. These are just simple sanity tests.
+
+static_assert(tuple_size_v<tuple<int>> == 1
+	      && tuple_size<tuple<int>>::value == 1, "");
+
+static_assert(tuple_size_v<tuple<int, int>> == 2
+	      && tuple_size<tuple<int, int>>::value == 2, "");

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [libstdc++ PATCH] More Fundamentals v1 variable templates
  2014-10-21  5:37     ` Ville Voutilainen
@ 2014-10-21 13:21       ` Jonathan Wakely
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Wakely @ 2014-10-21 13:21 UTC (permalink / raw)
  To: Ville Voutilainen; +Cc: gcc-patches, libstdc++

On 21/10/14 07:19 +0300, Ville Voutilainen wrote:
>No, no, no! Contributors must be punished, otherwise they will never learn! ;)
>Revised patch attached.

Thanks, committed to trunk.

>diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
>index 1ee8ddc..c797246 100644
>--- a/libstdc++-v3/include/Makefile.am
>+++ b/libstdc++-v3/include/Makefile.am
>@@ -644,7 +644,10 @@ experimental_headers = \
> 	${experimental_srcdir}/string_view \
> 	${experimental_srcdir}/string_view.tcc \
> 	${experimental_srcdir}/tuple \
>-	${experimental_srcdir}/type_traits
>+	${experimental_srcdir}/type_traits \
>+	${experimental_srcdir}/ratio \
>+	${experimental_srcdir}/chrono \
>+	${experimental_srcdir}/system_error \

I rearranged these files to keep them in alphabetical order (and
remove the trailing backslash).

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-10-21 13:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-18 20:23 [libstdc++ PATCH] More Fundamentals v1 variable templates Ville Voutilainen
2014-10-18 21:07 ` Ville Voutilainen
2014-10-20 12:43   ` Jonathan Wakely
2014-10-21  5:37     ` Ville Voutilainen
2014-10-21 13:21       ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).