function template
<locale>
std::isspace
template <class charT>
  bool isspace (charT c, const locale& loc);
Check if character is a white-space using locale
Checks whether c is a white-space character using the ctype facet of locale loc, returning the same as if ctype::is is called as:
|  
 | use_facet < ctype<charT> > (loc).is (ctype_base::space, c)
 | 
This function template overloads the C function isspace (defined in <cctype>).
Parameters
- c
- Character to be checked.
- loc
- Locale to be used. It shall have a ctype facet.
The template argument charT is the character type.
Return Value
true if indeed c is a white-space character.
false otherwise.
Example
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 
 | // isspace example (C++)
#include <iostream>       // std::cout
#include <string>         // std::string
#include <locale>         // std::locale, std::isspace
int main ()
{
  std::locale loc;
  std::string str="Example sentence to test isspace\n";
  char c;
  for (std::string::size_type i=0; i<str.length(); ++i)
  {
    c=str[i];
    if (std::isspace(c,loc)) c='\n';
    std::cout << c;
  }
  return 0;
}
 | 
Output:
| 
Example
sentence
to
test
isspace
 | 
Data races
Both loc and its ctype facet are accessed.
Exception safety
Strong guarantee: if an exception is thrown, there are no effects.
See also
- ctype
- Character type facet (class template
)
- isspace (cctype)
- Check if character is a white-space (function
)
- isgraph
- Check if character has graphical representation using locale (function template
)
- ispunct
- Check if character is a punctuation character using locale (function template
)
- isalnum
- Check if character is alphanumeric using locale (function template
)