2
0
mirror of https://github.com/boostorg/hana.git synced 2026-02-02 08:52:11 +00:00
Files
hana/test/record.fold_move_only.cpp
Louis Dionne 2c86ba2390 [Foldable] Rename the different fold variants
- Rename fold{l,r,l1,r1} to fold.{right,left} with overloads.
- Rename foldlM/foldrM to monadic_fold.{left,right}
- Add no-state variants of the monadic folds
- Improve the fold's documentation
- Deprecate the previous folds; they'll be removed soon

Fixes #18.
2015-03-30 17:29:37 -04:00

36 lines
781 B
C++

/*
@copyright Louis Dionne 2015
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
#include <boost/hana/foldable.hpp>
#include <boost/hana/record_macros.hpp>
#include <utility>
using namespace boost::hana;
struct moveonly {
moveonly() = default;
moveonly(moveonly const&) = delete;
moveonly(moveonly&&) = default;
};
struct T {
BOOST_HANA_DEFINE_RECORD_INTRUSIVE(T,
(moveonly, member1),
(moveonly, member2)
);
};
int f(int, moveonly) { return 1; }
int g(moveonly, int) { return 1; }
int main() {
// Folding a Record with move-only members should work when the
// Record is an rvalue.
fold.left(T{}, 0, f);
fold.right(T{}, 0, g);
}