@@ -1493,6 +1493,7 @@ class DoAllAction<FinalAction> {
1493
1493
// providing a call operator because even with a particular set of arguments
1494
1494
// they don't have a fixed return type.
1495
1495
1496
+ // We support conversion to OnceAction whenever the sub-action does.
1496
1497
template <typename R, typename ... Args,
1497
1498
typename std::enable_if<
1498
1499
std::is_convertible<FinalAction, OnceAction<R(Args...)>>::value,
@@ -1501,6 +1502,21 @@ class DoAllAction<FinalAction> {
1501
1502
return std::move (final_action_);
1502
1503
}
1503
1504
1505
+ // We also support conversion to OnceAction whenever the sub-action supports
1506
+ // conversion to Action (since any Action can also be a OnceAction).
1507
+ template <
1508
+ typename R, typename ... Args,
1509
+ typename std::enable_if<
1510
+ conjunction<
1511
+ negation<
1512
+ std::is_convertible<FinalAction, OnceAction<R(Args...)>>>,
1513
+ std::is_convertible<FinalAction, Action<R(Args...)>>>::value,
1514
+ int >::type = 0 >
1515
+ operator OnceAction<R(Args...)>() && { // NOLINT
1516
+ return Action<R (Args...)>(std::move (final_action_));
1517
+ }
1518
+
1519
+ // We support conversion to Action whenever the sub-action does.
1504
1520
template <
1505
1521
typename R, typename ... Args,
1506
1522
typename std::enable_if<
@@ -1580,16 +1596,16 @@ class DoAllAction<InitialAction, OtherActions...>
1580
1596
: Base({}, std::forward<U>(other_actions)...),
1581
1597
initial_action_(std::forward<T>(initial_action)) {}
1582
1598
1583
- template < typename R, typename ... Args,
1584
- typename std::enable_if<
1585
- conjunction <
1586
- // Both the initial action and the rest must support
1587
- // conversion to OnceAction.
1588
- std::is_convertible<
1589
- InitialAction,
1590
- OnceAction<void (InitialActionArgType<Args>...)>>,
1591
- std::is_convertible<Base, OnceAction<R(Args...)>>>::value,
1592
- int >::type = 0 >
1599
+ // We support conversion to OnceAction whenever both the initial action and
1600
+ // the rest support conversion to OnceAction.
1601
+ template <
1602
+ typename R, typename ... Args,
1603
+ typename std::enable_if<
1604
+ conjunction< std::is_convertible<
1605
+ InitialAction,
1606
+ OnceAction<void (InitialActionArgType<Args>...)>>,
1607
+ std::is_convertible<Base, OnceAction<R(Args...)>>>::value,
1608
+ int >::type = 0 >
1593
1609
operator OnceAction<R(Args...)>() && { // NOLINT
1594
1610
// Return an action that first calls the initial action with arguments
1595
1611
// filtered through InitialActionArgType, then forwards arguments directly
@@ -1612,12 +1628,34 @@ class DoAllAction<InitialAction, OtherActions...>
1612
1628
};
1613
1629
}
1614
1630
1631
+ // We also support conversion to OnceAction whenever the initial action
1632
+ // supports conversion to Action (since any Action can also be a OnceAction).
1633
+ //
1634
+ // The remaining sub-actions must also be compatible, but we don't need to
1635
+ // special case them because the base class deals with them.
1636
+ template <
1637
+ typename R, typename ... Args,
1638
+ typename std::enable_if<
1639
+ conjunction<
1640
+ negation<std::is_convertible<
1641
+ InitialAction,
1642
+ OnceAction<void (InitialActionArgType<Args>...)>>>,
1643
+ std::is_convertible<InitialAction,
1644
+ Action<void (InitialActionArgType<Args>...)>>,
1645
+ std::is_convertible<Base, OnceAction<R(Args...)>>>::value,
1646
+ int >::type = 0 >
1647
+ operator OnceAction<R(Args...)>() && { // NOLINT
1648
+ return DoAll (
1649
+ Action<void (InitialActionArgType<Args>...)>(std::move (initial_action_)),
1650
+ std::move (static_cast <Base&>(*this )));
1651
+ }
1652
+
1653
+ // We support conversion to Action whenever both the initial action and the
1654
+ // rest support conversion to Action.
1615
1655
template <
1616
1656
typename R, typename ... Args,
1617
1657
typename std::enable_if<
1618
1658
conjunction<
1619
- // Both the initial action and the rest must support conversion to
1620
- // Action.
1621
1659
std::is_convertible<const InitialAction&,
1622
1660
Action<void (InitialActionArgType<Args>...)>>,
1623
1661
std::is_convertible<const Base&, Action<R(Args...)>>>::value,
0 commit comments