Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      operator==, !=, <, <=, >, >=(std::experimental::optional)

      From cppreference.com
      <cpp‎ |experimental‎ |optional
       
       
       
       
       
      Defined in header<experimental/optional>
      Compare twooptional objects
      template<class T>
      constexprbool operator==(const optional<T>& lhs,const optional<T>& rhs);
      (1)(library fundamentals TS)
      template<class T>
      constexprbool operator!=(const optional<T>& lhs,const optional<T>& rhs);
      (2)(library fundamentals TS)
      template<class T>
      constexprbool operator<(const optional<T>& lhs,const optional<T>& rhs);
      (3)(library fundamentals TS)
      template<class T>
      constexprbool operator<=(const optional<T>& lhs,const optional<T>& rhs);
      (4)(library fundamentals TS)
      template<class T>
      constexprbool operator>(const optional<T>& lhs,const optional<T>& rhs);
      (5)(library fundamentals TS)
      template<class T>
      constexprbool operator>=(const optional<T>& lhs,const optional<T>& rhs);
      (6)(library fundamentals TS)
      Compare anoptional object with anullopt
      template<class T>
      constexprbool operator==(const optional<T>& opt,std::nullopt_t)noexcept;
      (7)(library fundamentals TS)
      template<class T>
      constexprbool operator==(std::nullopt_t,const optional<T>& opt)noexcept;
      (8)(library fundamentals TS)
      template<class T>
      constexprbool operator!=(const optional<T>& opt,std::nullopt_t)noexcept;
      (9)(library fundamentals TS)
      template<class T>
      constexprbool operator!=(std::nullopt_t,const optional<T>& opt)noexcept;
      (10)(library fundamentals TS)
      template<class T>
      constexprbool operator<(const optional<T>& opt,std::nullopt_t)noexcept;
      (11)(library fundamentals TS)
      template<class T>
      constexprbool operator<(std::nullopt_t,const optional<T>& opt)noexcept;
      (12)(library fundamentals TS)
      template<class T>
      constexprbool operator<=(const optional<T>& opt,std::nullopt_t)noexcept;
      (13)(library fundamentals TS)
      template<class T>
      constexprbool operator<=(std::nullopt_t,const optional<T>& opt)noexcept;
      (14)(library fundamentals TS)
      template<class T>
      constexprbool operator>(const optional<T>& opt,std::nullopt_t)noexcept;
      (15)(library fundamentals TS)
      template<class T>
      constexprbool operator>(std::nullopt_t,const optional<T>& opt)noexcept;
      (16)(library fundamentals TS)
      template<class T>
      constexprbool operator>=(const optional<T>& opt,std::nullopt_t)noexcept;
      (17)(library fundamentals TS)
      template<class T>
      constexprbool operator>=(std::nullopt_t,const optional<T>& opt)noexcept;
      (18)(library fundamentals TS)
      Compare anoptional object with aT
      template<class T>
      constexprbool operator==(const optional<T>& opt,const T& value);
      (19)(library fundamentals TS)
      template<class T>
      constexprbool operator==(const T& value,const optional<T>& opt);
      (20)(library fundamentals TS)
      template<class T>
      constexprbool operator!=(const optional<T>& opt,const T& value);
      (21)(library fundamentals TS)
      template<class T>
      constexprbool operator!=(const T& value,const optional<T>& opt);
      (22)(library fundamentals TS)
      template<class T>
      constexprbool operator<(const optional<T>& opt,const T& value);
      (23)(library fundamentals TS)
      template<class T>
      constexprbool operator<(const T& value,const optional<T>& opt);
      (24)(library fundamentals TS)
      template<class T>
      constexprbool operator<=(const optional<T>& opt,const T& value);
      (25)(library fundamentals TS)
      template<class T>
      constexprbool operator<=(const T& value,const optional<T>& opt);
      (26)(library fundamentals TS)
      template<class T>
      constexprbool operator>(const optional<T>& opt,const T& value);
      (27)(library fundamentals TS)
      template<class T>
      constexprbool operator>(const T& value,const optional<T>& opt);
      (28)(library fundamentals TS)
      template<class T>
      constexprbool operator>=(const optional<T>& opt,const T& value);
      (29)(library fundamentals TS)
      template<class T>
      constexprbool operator>=(const T& value,const optional<T>& opt);
      (30)(library fundamentals TS)

      Performs comparison operations onoptional objects.

      1-6) Compares twooptional objects,lhs andrhs. The contained values are compared (usingoperator== for(1,2) andoperator< for(3-6)) only if bothlhs andrhs contain values. Otherwise,
      • lhs is consideredequal torhs if, and only if, bothlhs andrhs do not contain a value.
      • lhs is consideredless thanrhs if, and only if,rhs contains a value andlhs does not.
      7-18) Comparesopt with anullopt. Equivalent to (1-6) when comparing to anoptional that does not contain a value.
      19-30) Comparesopt with avalue. The values are compared (usingoperator== for(19-22) andoperator< for(23-30)) only ifopt contains a value. Otherwise,opt is consideredless thanvalue.

      [edit]Parameters

      lhs, rhs, opt - anoptional object to compare
      value - value to compare to the contained value
      Type requirements
      -
      T must meet the requirements ofEqualityComparable in order to use overloads (1,2).

      [edit]Return value

      1) Ifbool(lhs)!=bool(rhs), returnsfalse.
      Otherwise, ifbool(lhs)==false (and sobool(rhs)==false as well), returnstrue.
      Otherwise, returns*lhs==*rhs.
      2) Returns!(lhs== rhs).
      3) Ifbool(rhs)==false returnsfalse.
      Otherwise, ifbool(lhs)==false, returnstrue.
      Otherwise returns*x<*y.
      4) Returns!(rhs< lhs).
      5) Returnsrhs< lhs.
      6) Returns!(lhs< rhs).
      7,8) Returns!opt.
      9,10) Returnsbool(opt).
      11) Returnsfalse.
      12) Returnsbool(opt).
      13) Returns!opt.
      14) Returnstrue.
      15) Returnsbool(opt).
      16) Returnsfalse.
      17) Returnstrue.
      18) Returns!opt.
      19) Returnsbool(opt)?*opt== value:false.
      20) Returnsbool(opt)? value==*opt:false.
      21) Returnsbool(opt)?!(*opt== value):true.
      22) Returnsbool(opt)?!(value==*opt):true.
      23) Returnsbool(opt)?*opt< value:true.
      24) Returnsbool(opt)? value<*opt:false.
      25) Returns!(opt> value).
      26) Returns!(value> opt).
      27) Returnsbool(opt)? value<*opt:false.
      28) Returnsbool(opt)?*opt< value:true.
      29) Returns!(opt< value).
      30) Returns!(value< opt).

      [edit]Exceptions

      1-6) (none)
      19-30) (none)
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/experimental/optional/operator_cmp&oldid=157743"

      [8]ページ先頭

      ©2009-2026 Movatter.jp