function template
<locale>

std::isgraph

template <class charT>  bool isgraph (charT c, const locale& loc);
Check if character has graphical representation using locale
Checks whether c has graphical representation using the ctype facet of locale loc, returning the same as if ctype::is is called as

1
use_facet < ctype<charT> > (loc).is (ctype_base::graph, c)

This function template overloads the C function isgraph (defined in <cctype>).

引數

c
要檢查的字元。
loc
要使用的 locale。它必須具有 ctype 方面。

模板引數 charT 是字元型別。

返回值

true if indeed c has graphical representation.
否則返回 false

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// isgraph example (C++)
#include <iostream>       // std::cout
#include <fstream>        // std::ifstream
#include <locale>         // std::locale, std::isgraph

int main ()
{
  std::locale loc;
  std::ifstream myfile ("myfile.txt");
  char c;
  while (myfile.good())
  {
    myfile >> c;
    if (std::isgraph(c,loc)) std::cout << c;
  }
  myfile.close();
  return 0;
}

This example prints out the contents of myfile.txt without spaces and special characters, i.e. only prints out the characters that qualify as isgraph.

資料競爭

將訪問 loc 及其 ctype 方面。

異常安全

強保證:如果丟擲異常,則沒有效果。

另見