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

履歴 編集

function template
<scoped_allocator>

std::operator!=(C++11)

namespace std {
  // operator==により、以下のオーバーロードが使用可能になる (C++20)
  template <class OuterA1, class OuterA2, class... InnerAllocs>
  bool operator!=(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
                  const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept; // (1) C++11
}

概要

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

戻り値

!(a == b)

#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 << "not equal" << std::endl;
  }
  else {
    std::cout << "equal" << std::endl;
  }
}

出力

equal

バージョン

言語

  • C++11

処理系

参照