forked from boostorg/fusion
missing make_pair() for r-value refs (#264)
* missing make_pair() for r-value refs hello guys! the `make_pair()` for r-value refs is required for r-value, otherwise `non-copyable` but `movable` can be constructed. thanks! * fix for prev commit conditional support for r-values was fixed * the test case was added * fix for prev commit * Update Jamfile * one more fix for Jamfile * the forgotten r-value ctor was added * ah, they should be conditional
This commit is contained in:
@ -120,6 +120,17 @@ namespace boost { namespace fusion
|
||||
return pair<First, typename detail::as_fusion_element<Second>::type>(val);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
template <typename First, typename Second>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline typename result_of::make_pair<First,Second>::type
|
||||
make_pair(Second&& val)
|
||||
{
|
||||
return pair<First, typename detail::as_fusion_element<Second>::type>(
|
||||
BOOST_FUSION_FWD_ELEM(Second, val));
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename First, typename Second>
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& os, pair<First, Second> const& p)
|
||||
|
@ -273,6 +273,10 @@ project
|
||||
[ compile support/unused.cpp ]
|
||||
[ compile support/detail/tag_of_fallback.cpp ]
|
||||
|
||||
[ compile-fail support/make_pair_r-value.cpp ]
|
||||
[ compile support/make_pair_r-value.cpp
|
||||
: [ requires cxx11_rvalue_references ] ]
|
||||
|
||||
# [ compile-fail xxx.cpp ]
|
||||
|
||||
;
|
||||
|
24
test/support/make_pair_r-value.cpp
Normal file
24
test/support/make_pair_r-value.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2022 niXman (github dot nixman at pm.me)
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
|
||||
#include <boost/fusion/support/pair.hpp>
|
||||
|
||||
struct noncopyable_type {
|
||||
noncopyable_type(const noncopyable_type &) = delete;
|
||||
noncopyable_type& operator=(const noncopyable_type &) = delete;
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
noncopyable_type(noncopyable_type &&) = default;
|
||||
noncopyable_type& operaotr=(noncopyable_type &&) = default;
|
||||
#endif
|
||||
};
|
||||
|
||||
int main() {
|
||||
using namespace boost::fusion;
|
||||
|
||||
pair<int, noncopyable_type> val = make_pair<int>(noncopyable_type{});
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user