Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      boolean-testable

      From cppreference.com
      <cpp‎ |concepts
       
       
      Concepts library
       
      template<class B>
      concept __boolean_testable_impl=std::convertible_to<B,bool>;
      (1)(since C++20)
      (exposition only*)
      template<class B>

      concept boolean-testable=
          __boolean_testable_impl<B>&&
          requires(B&& b){
             {!std::forward<B>(b)}-> __boolean_testable_impl;

         };
      (2)(since C++20)
      (exposition only*)

      The exposition-only conceptboolean-testable specifies the requirements for expressions that are convertible tobool and for which the logical operators have the usual behavior (includingshort-circuiting), even for two differentboolean-testable types.

      Formally, to model the exposition-only concept__boolean_testable_impl, the type must not define any memberoperator&& andoperator||, and no viable non-memberoperator&& andoperator|| may be visible byargument-dependent lookup. Additionally, given an expressione such thatdecltype((e)) isB,boolean-testable is modeled only ifbool(e)==!bool(!e).

      [edit]Equality preservation

      Expressions declared inrequires expressions of the standard library concepts are required to beequality-preserving (except where stated otherwise).

      [edit]Notes

      Examples ofboolean-testable types includebool,std::true_type,std::bitset<N>::reference, andint*.

      [edit]References

      • C++23 standard (ISO/IEC 14882:2024):
      • 18.5.2 Boolean testability [concept.booleantestable]
      • C++20 standard (ISO/IEC 14882:2020):
      • 18.5.2 Boolean testability [concept.booleantestable]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/concepts/boolean-testable&oldid=175953"

      [8]ページ先頭

      ©2009-2025 Movatter.jp