* [patch] libstdc++/65978 LWG 2275 and 2301, constexpr forward_as_tuple and tie
@ 2015-05-02 11:20 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2015-05-02 11:20 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 175 bytes --]
Two easy DRs to implement. We even had the tests half written.
Tested x86_64-linux and powerpc64l2-linux, committed to trunk.
I'll probably backport this in a week or two.
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 3333 bytes --]
commit c1a6989fbdad9870cdd2240d5fda58054d0ba5ae
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Sat May 2 11:29:17 2015 +0100
PR libstdc++/65978
* include/std/tuple (forward_as_tuple, tie): Add constexpr.
* testsuite/20_util/tuple/creation_functions/constexpr.cc: Uncomment
and fix tests for forward_as_tuple and tie.
diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple
index e500a76..ad132bd 100644
--- a/libstdc++-v3/include/std/tuple
+++ b/libstdc++-v3/include/std/tuple
@@ -970,8 +970,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return __result_type(std::forward<_Elements>(__args)...);
}
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2275. Why is forward_as_tuple not constexpr?
template<typename... _Elements>
- tuple<_Elements&&...>
+ constexpr tuple<_Elements&&...>
forward_as_tuple(_Elements&&... __args) noexcept
{ return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
@@ -1120,9 +1122,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return __concater::_S_do(std::forward<_Tpls>(__tpls)...);
}
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2301. Why is tie not constexpr?
/// tie
template<typename... _Elements>
- inline tuple<_Elements&...>
+ constexpr tuple<_Elements&...>
tie(_Elements&... __args) noexcept
{ return tuple<_Elements&...>(__args...); }
diff --git a/libstdc++-v3/testsuite/20_util/tuple/creation_functions/constexpr.cc b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/constexpr.cc
index 2c47fbb..3ededfc 100644
--- a/libstdc++-v3/testsuite/20_util/tuple/creation_functions/constexpr.cc
+++ b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/constexpr.cc
@@ -45,49 +45,51 @@ test_make_tuple()
}
}
-#if 0
// forward_as_tuple
void
test_forward_as_tuple()
{
{
- typedef std::tuple<int, float> tuple_type;
+ static int i(22);
+ static float f(22.222);
+ typedef std::tuple<int&, float&&> tuple_type;
constexpr tuple_type p1 __attribute__((unused))
- = std::forward_as_tuple(22, 22.222);
+ = std::forward_as_tuple(i, std::move(f));
}
{
- typedef std::tuple<int, float, int> tuple_type;
+ static int i(22);
+ static float f(22.222);
+ static int ii(77799);
+
+ typedef std::tuple<int&, float&, int&&> tuple_type;
constexpr tuple_type p1 __attribute__((unused))
- = std::forward_as_tuple(22, 22.222, 77799);
+ = std::forward_as_tuple(i, f, std::move(ii));
}
}
-#endif
-#if 0
// tie
void
test_tie()
{
{
- int i(22);
- float f(22.222);
- typedef std::tuple<int, float> tuple_type;
+ static int i(22);
+ static float f(22.222);
+ typedef std::tuple<int&, float&> tuple_type;
constexpr tuple_type p1 __attribute__((unused))
= std::tie(i, f);
}
{
- int i(22);
- float f(22.222);
- int ii(77799);
+ static int i(22);
+ static float f(22.222);
+ static const int ii(77799);
- typedef std::tuple<int, float, int> tuple_type;
+ typedef std::tuple<int&, float&, const int&> tuple_type;
constexpr tuple_type p1 __attribute__((unused))
= std::tie(i, f, ii);
}
}
-#endif
// get
void
@@ -124,6 +126,8 @@ int
main()
{
test_make_tuple();
+ test_forward_as_tuple();
+ test_tie();
test_get();
test_tuple_cat();
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-05-02 11:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-02 11:20 [patch] libstdc++/65978 LWG 2275 and 2301, constexpr forward_as_tuple and tie 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).