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::char_traits::not_eof - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. string
  3. char_traits
  4. not_eof

最終更新日時: 2026年09月16日 21時49分06秒 (JST)
rotarymars が更新

履歴 編集

function
<string>

std::char_traits::not_eof

static int_type not_eof(const int_type& c);             // C++98
static constexpr int_type not_eof(int_type c) noexcept; // C++11

概要

文字がファイル終端文字(EOF)ではないかを判定する。

戻り値

eq_int_type(c, eof()) == falseの場合はcを返す。そうでない場合は、eq_int_type(f, eof()) == falseとなるような値fを返す。

つまり、EOF以外の値が渡されたら渡された値を返し、EOFが渡されたらEOF以外の値を返す。

計算量

定数時間

例

#include <iostream>
#include <string>

int main()
{
  using traits = std::char_traits<char>;

  std::cout << std::boolalpha;

  // EOFではない値を渡すと、渡した値が返される
  {
    int a = traits::to_int_type('a');
    int result = traits::not_eof(a);
    std::cout << (a == result) << std::endl;
  }

  // EOFを渡すと、EOF以外の値が返される
  {
    int result = traits::not_eof(traits::eof());
    std::cout << (result != traits::eof()) << std::endl;
  }
}

出力例

true
true

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.