aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2015-05-13 14:12:48 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2015-05-13 14:12:48 +0100
commitac68f97cfe269d57f3d6d7ed2960cb738eb192e8 (patch)
tree6ee8f3f658e15921215d5f80edac7274c7a0b9b0 /libstdc++-v3
parent681a3d868dc7f72c062905e9b4d17e206f2ede81 (diff)
downloadgcc-ac68f97cfe269d57f3d6d7ed2960cb738eb192e8.zip
gcc-ac68f97cfe269d57f3d6d7ed2960cb738eb192e8.tar.gz
gcc-ac68f97cfe269d57f3d6d7ed2960cb738eb192e8.tar.bz2
tuple (apply): Handle pointers to member (LWG 2418).
* include/experimental/tuple (apply): Handle pointers to member (LWG 2418). * include/std/functional (_Mem_fn_base): Make constructors constexpr. (_Maybe_wrap_member_pointer::__do_wrap): Make constexpr. * testsuite/experimental/tuple/apply.cc: Test pointer to member. From-SVN: r223158
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog6
-rw-r--r--libstdc++-v3/include/experimental/tuple7
-rw-r--r--libstdc++-v3/include/std/functional10
-rw-r--r--libstdc++-v3/testsuite/experimental/tuple/apply.cc14
4 files changed, 31 insertions, 6 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 251948e..a22a565 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,11 @@
2015-05-13 Jonathan Wakely <jwakely@redhat.com>
+ * include/experimental/tuple (apply): Handle pointers to member (LWG
+ 2418).
+ * include/std/functional (_Mem_fn_base): Make constructors constexpr.
+ (_Maybe_wrap_member_pointer::__do_wrap): Make constexpr.
+ * testsuite/experimental/tuple/apply.cc: Test pointer to member.
+
* include/bits/random.h (seed_seq): More noexcept (LWG 2440).
* include/bits/alloc_traits.h (_S_max_size): Implement LWG 2466.
diff --git a/libstdc++-v3/include/experimental/tuple b/libstdc++-v3/include/experimental/tuple
index 4baede4..aa25c57 100644
--- a/libstdc++-v3/include/experimental/tuple
+++ b/libstdc++-v3/include/experimental/tuple
@@ -36,6 +36,7 @@
#else
#include <tuple>
+#include <functional>
namespace std _GLIBCXX_VISIBILITY(default)
{
@@ -54,7 +55,11 @@ _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))...); }
+ {
+ using _Wrap = _Maybe_wrap_member_pointer<decay_t<_Fn>>;
+ return _Wrap::__do_wrap(std::forward<_Fn>(f))(
+ get<_Idx>(forward<_Tuple>(t))...);
+ }
template <typename _Fn, typename _Tuple>
constexpr decltype(auto)
diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional
index 946cf63..7dd149a 100644
--- a/libstdc++-v3/include/std/functional
+++ b/libstdc++-v3/include/std/functional
@@ -572,7 +572,7 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type)
public:
using result_type = typename _Traits::__result_type;
- explicit _Mem_fn_base(_Pmf __pmf) : _M_pmf(__pmf) { }
+ explicit constexpr _Mem_fn_base(_Pmf __pmf) : _M_pmf(__pmf) { }
// Handle objects
template<typename... _Args, typename _Req
@@ -671,7 +671,7 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type)
friend struct _Bind_check_arity;
public:
- explicit
+ explicit constexpr
_Mem_fn_base(_Res _Class::*__pm) noexcept : _M_pm(__pm) { }
// Handle objects
@@ -1002,11 +1002,11 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type)
{
typedef _Tp type;
- static const _Tp&
+ static constexpr const _Tp&
__do_wrap(const _Tp& __x)
{ return __x; }
- static _Tp&&
+ static constexpr _Tp&&
__do_wrap(_Tp&& __x)
{ return static_cast<_Tp&&>(__x); }
};
@@ -1021,7 +1021,7 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type)
{
typedef _Mem_fn<_Tp _Class::*> type;
- static type
+ static constexpr type
__do_wrap(_Tp _Class::* __pm)
{ return type(__pm); }
};
diff --git a/libstdc++-v3/testsuite/experimental/tuple/apply.cc b/libstdc++-v3/testsuite/experimental/tuple/apply.cc
index 88e174d..e52962b 100644
--- a/libstdc++-v3/testsuite/experimental/tuple/apply.cc
+++ b/libstdc++-v3/testsuite/experimental/tuple/apply.cc
@@ -41,9 +41,23 @@ test02()
VERIFY( i == 3 );
}
+struct F
+{
+ int f(int i, int j) const { return i + j; }
+};
+
+void
+test03()
+{
+ auto t = std::make_tuple(F{}, 1, 2);
+ int r = std::experimental::apply(&F::f, t);
+ VERIFY( r == 3 );
+}
+
int
main()
{
test01();
test02();
+ test03();
}