• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <memory_resource>

    std::pmr::operator!=

    namespace std::pmr {
      // operator==により、以下のオーバーロードが使用可能になる (C++20)
      template <class T1, class T2>
      bool operator!=(const polymorphic_allocator<T1>& a,
                      const polymorphic_allocator<T2>& b) noexcept; // (1) C++17
    }
    

    概要

    2つのpolymorphic_allocatorオブジェクトを非等値比較する。

    戻り値

    !(a == b)

    備考

    この演算子はC++20以降、対応する==を利用して導出される。

    #include <iostream>
    #include <memory_resource>
    
    int main()
    {
      auto mr = std::pmr::monotonic_buffer_resource{};
      std::pmr::polymorphic_allocator<int> alloc{ &mr };
      std::pmr::polymorphic_allocator<int> alloc2{};
      std::pmr::polymorphic_allocator<double> alloc3{ &mr };
    
      std::cout << std::boolalpha;
      std::cout << (alloc != alloc2) << std::endl;
      std::cout << (alloc != alloc) << std::endl;
      //同じmemory_resourceを利用していればfalse
      std::cout << (alloc != alloc3) << std::endl;
    }
    

    出力

    true
    false
    false
    

    バージョン

    言語

    • C++17

    処理系

    • Clang: ??
    • GCC: 9.1 (2) , 13.1 (1)
    • Visual C++: 2017 update 6 (2) , 2022 17.4 (1)

    関連項目

    参照