GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • cpprefjp - C++日本語リファレンス
  • GitHub Project

This view

  • Original page
  • New address

GeezerVison is showing cpprefjp.github.io — std::operator!= - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. string_view
  3. basic_string_view
  4. operator!=

最終更新日時: 2026年09月11日 13時06分31秒 (JST)
Akira Takahashi が更新

履歴 編集

function template
<string_view>

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

namespace std {
  // operator==により、以下の演算子が使用可能になる (C++20)
  template <class CharT, class Traits>
  constexpr bool operator!=(basic_string_view<CharT, Traits> x,
                            basic_string_view<CharT, Traits> y) noexcept; // (1) C++17
}

概要

basic_string_viewオブジェクトの非等値比較を行う。

戻り値

return x.compare(y) != 0;

例

#include <iostream>
#include <string_view>

int main()
{
  std::string_view a = "aaa";
  std::string_view b = "bbb";

  if (a != b) {
    std::cout << "not equal" << std::endl;
  }
  else {
    std::cout << "equal" << std::endl;
  }
}

出力

not equal

バージョン

言語

  • C++17

処理系

  • Clang: 4.0 ✅
  • GCC: 7.1 ✅
  • Visual C++: ??

参照

  • P1614R2 The Mothership has Landed
    • C++20での三方比較演算子の追加と、関連する演算子の自動導出
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.