function template
<locale>

std::isupper

template <class charT>  bool isupper (charT c, const locale& loc);
使用 locale 檢查字元是否為大寫字母
使用 locale locctype 區域因子,檢查 c 是否為大寫字母,返回值與呼叫 ctype::is 相同,形式為

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

此函式模板過載了 C 函式 isupper(在 <cctype> 中定義)。

引數

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

模板引數 charT 是字元型別。

返回值

如果 c 確實是大寫字母,則返回 true
否則返回 false

示例

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

int main ()
{
  std::locale loc;
  std::string str="Test String.\n";
  char c;
  for (std::string::size_type i=0; i<str.length(); ++i)
  {
    c=str[i];
    if (std::isupper(c,loc)) c=std::tolower(c,loc);
    std::cout << c;
  }
  return 0;
}

輸出
test string. 


資料競爭

將訪問 loc 及其 ctype 方面。

異常安全

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

另見