• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function template
    <scoped_allocator>

    std::operator==

    namespace std {
      template <class OuterA1, class OuterA2, class... InnerAllocs>
      bool operator==(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
                      const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;
    }
    

    概要

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

    戻り値

    sizeof...(InnerAlloc) == 0であるならば、a.outer_allocator() == b.outer_allocator()の結果を返す。

    そうでなければ、a.outer_allocator() == b.outer_allocator() && a.inner_allocator() == b.inner_allocator()の結果を返す。

    #include <iostream>
    #include <vector>
    #include <string>
    
    #include <scoped_allocator>
    
    template <class T>
    using alloc_t = std::allocator<T>;
    
    // コンテナの要素(Inner)
    using string = std::basic_string<
      char,
      std::char_traits<char>,
      alloc_t<char>
    >;
    
    // コンテナ(Outer)
    template <class T>
    using vector = std::vector<
      T,
      std::scoped_allocator_adaptor<alloc_t<T>, alloc_t<typename T::value_type>>
    >;
    
    int main()
    {
      vector<string>::allocator_type a, b;
    
      if (a == b) {
        std::cout << "equal" << std::endl;
      }
      else {
        std::cout << "not equal" << std::endl;
      }
    }
    

    出力

    equal
    

    バージョン

    言語

    • C++11

    処理系