@@ -1586,59 +1586,20 @@ constexpr auto unsafe_narrow( X&& x ) noexcept -> decltype(auto)
1586
1586
1587
1587
// -----------------------------------------------------------------------
1588
1588
//
1589
- // strict_value: a strong typedef-like helper for value types
1589
+ // has_flags: query whether a flag_enum value has all flags in 'flags' set
1590
1590
//
1591
- // Intended for use as an underlying type for types/variables where you
1592
- // don't want implicit conversions or comparisons to happen between
1593
- // values even if they may share the same underlying type (e.g.,
1594
- // Color::Red and CardGame::Poker may both be represented as an `int`
1595
- // but shouldn't be interconvertible or intercomparable)
1596
- //
1597
- // Used by the `enum` and `flag_enum` metafunctions
1591
+ // flags set of flags to check
1598
1592
//
1593
+ // Returns a function object that takes a 'value' of the same type as
1594
+ // 'flags', and evaluates to true if and only if 'value' has set all of
1595
+ // the bits set in 'flags'
1596
+ //
1599
1597
// -----------------------------------------------------------------------
1600
1598
//
1601
- template <typename T, typename Tag, bool BitwiseOps>
1602
- class strict_value {
1603
- T t = {};
1604
- public:
1605
- explicit constexpr strict_value () { }
1606
-
1607
- template <typename U>
1608
- explicit constexpr strict_value (U const & u) : t{unsafe_narrow<T>(u)} { }
1609
-
1610
- template <typename U> requires std::is_convertible_v<T,U>
1611
- explicit constexpr operator U () const { return t; }
1612
-
1613
- template <typename U> requires std::is_convertible_v<T,U>
1614
- explicit constexpr operator U () { return t; }
1615
-
1616
- constexpr auto operator <=>( strict_value const & ) const -> std::strong_ordering = default ;
1617
-
1618
- auto to_string () const -> std::string { return Tag::to_string (*this ); }
1619
-
1620
- friend auto operator <<(std::ostream& o, strict_value const & v) -> std::ostream& { return o << v.to_string (); }
1621
-
1622
- // Bitwise operations
1623
-
1624
- constexpr auto operator |=( strict_value const & that ) -> strict_value requires BitwiseOps { t |= that.t ; return *this ; }
1625
- constexpr auto operator &=( strict_value const & that ) -> strict_value requires BitwiseOps { t &= that.t ; return *this ; }
1626
- constexpr auto operator ^=( strict_value const & that ) -> strict_value requires BitwiseOps { t ^= that.t ; return *this ; }
1627
-
1628
- constexpr auto operator | ( strict_value const & that ) const -> strict_value requires BitwiseOps { return strict_value (t | that.t ); }
1629
- constexpr auto operator & ( strict_value const & that ) const -> strict_value requires BitwiseOps { return strict_value (t & that.t ); }
1630
- constexpr auto operator ^ ( strict_value const & that ) const -> strict_value requires BitwiseOps { return strict_value (t ^ that.t ); }
1631
-
1632
- constexpr auto has ( strict_value const & that ) const -> bool requires BitwiseOps { return t & that.t ; }
1633
-
1634
- constexpr auto set ( strict_value const & that ) -> void requires BitwiseOps { t |= that.t ; }
1635
- constexpr auto clear ( strict_value const & that ) -> void requires BitwiseOps { t &= ~that.t ; }
1636
- };
1637
-
1638
- template <typename T, typename Tag>
1639
- auto has_flags (strict_value<T, Tag, true > flags)
1599
+ template <typename T>
1600
+ auto has_flags (T flags)
1640
1601
{
1641
- return [=](strict_value<T, Tag, true > value) { return (value & flags) == flags; };
1602
+ return [=](T value) { return (value & flags) == flags; };
1642
1603
}
1643
1604
1644
1605
0 commit comments