最終更新日時(UTC):
が更新

履歴 編集

class template
<functional>

std::logical_not

namespace std {
  // C++03
  template <typename T>
  struct logical_not {
    bool operator ()(const T& x) const;
    using argument_type = T;
    using result_type   = bool;
  };

  // C++14
  template <class T = void>
  struct logical_not {
    bool constexpr operator()(const T& x) const;
    using argument_type = T;
    using result_type   = bool;
  };

  template <>
  struct logical_not<void> {
    template <class T> constexpr auto operator()(T&& t) const
      -> decltype(!std::forward<T>(t));
    using is_transparent = unspecified;
  };

  // C++20
  template <class T = void>
  struct logical_not {
    bool constexpr operator()(const T& x) const;
  };

  template <>
  struct logical_not<void> {
    template <class T> constexpr auto operator()(T&& t) const
      -> decltype(!std::forward<T>(t));
    using is_transparent = unspecified;
  };
}

概要

logical_notクラスは、論理否定(NOT)を計算する関数オブジェクトである。

この関数オブジェクトは一切のメンバ変数を持たず、状態を保持しない。

メンバ関数

名前 説明
operator () !x と等価

メンバ型

名前 説明
argument_type operator() の引数の型。T と等価(Tvoid 以外の場合のみ)
result_type operator() の戻り値の型。bool と等価(Tvoid 以外の場合のみ)
is_transparent operator() が関数テンプレートである事を示すタグ型。
実装依存の型であるがあくまでタグ型であり、型そのものには意味はない。(Tvoid の場合のみ)

#include <iostream>
#include <functional>

int main()
{
  std::cout << std::boolalpha << std::logical_not<bool>()(false) << std::endl;
}

出力

true

参照