File tree Expand file tree Collapse file tree 3 files changed +40
-3
lines changed Expand file tree Collapse file tree 3 files changed +40
-3
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,13 @@ BOOST_HANA_NAMESPACE_BEGIN
106106 // ! @relates hana::pair
107107 // !
108108 // !
109+ // ! @note
110+ // ! `make<pair_tag>` supports reference wrappers. When a reference wrapper
111+ // ! is passed to it, the resulting `hana::pair` will hold a reference
112+ // ! to the object enclosed in the reference wrapper instead of the object
113+ // ! itself.
114+ // !
115+ // !
109116 // ! Example
110117 // ! -------
111118 // ! @include example/pair/make.cpp
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ Distributed under the Boost Software License, Version 1.0.
1414
1515#include < boost/hana/basic_tuple.hpp>
1616#include < boost/hana/config.hpp>
17- #include < boost/hana/detail/decay .hpp>
17+ #include < boost/hana/detail/as_container_element .hpp>
1818#include < boost/hana/detail/intrinsics.hpp>
1919#include < boost/hana/detail/operators/adl.hpp>
2020#include < boost/hana/detail/operators/comparable.hpp>
@@ -122,8 +122,8 @@ BOOST_HANA_NAMESPACE_BEGIN
122122 struct make_impl <pair_tag> {
123123 template <typename F, typename S>
124124 static constexpr pair<
125- typename detail::decay <F>::type ,
126- typename detail::decay <S>::type
125+ detail::as_container_element_t <F>,
126+ detail::as_container_element_t <S>
127127 > apply (F&& f, S&& s) {
128128 return {static_cast <F&&>(f), static_cast <S&&>(s)};
129129 }
Original file line number Diff line number Diff line change 1+ /*
2+ @copyright Louis Dionne 2015
3+ Distributed under the Boost Software License, Version 1.0.
4+ (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
5+ */
6+
7+ #include < boost/hana/assert.hpp>
8+ #include < boost/hana/first.hpp>
9+ #include < boost/hana/pair.hpp>
10+ #include < boost/hana/second.hpp>
11+
12+ #include < functional>
13+ namespace hana = boost::hana;
14+
15+
16+ int main () {
17+ int i = 0 ;
18+ char c = ' x' ;
19+ hana::pair<int &, char const &> refs = hana::make_pair (std::ref (i), std::cref (c));
20+
21+ int & i_ref = hana::first (refs);
22+ BOOST_HANA_RUNTIME_CHECK (&i_ref == &i);
23+
24+ i_ref = 3 ;
25+ BOOST_HANA_RUNTIME_CHECK (i == 3 );
26+
27+ char const & c_ref = hana::second (refs);
28+ BOOST_HANA_RUNTIME_CHECK (&c_ref == &c);
29+ BOOST_HANA_RUNTIME_CHECK (c == ' x' );
30+ }
You can’t perform that action at this time.
0 commit comments