function template
<locale>

std::isxdigit

template <class charT>
  bool isxdigit (charT c, const locale& loc);
Check if character is hexadecimal digit using locale
Checks whether c is a hexadecimal digit 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::xdigit, c)


This function template overloads the C function isxdigit (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 hexadecimal digit character.
false otherwise.

Example

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

int main ()
{
  std::locale loc;
  std::string str="ffff";
  if ( std::isxdigit(str[0],loc) )
  {
    int number;
    std::stringstream(str) >> std::hex >> number;
    std::cout << "The hexadecimal number " << std::hex << number;
    std::cout << " is " << std::dec << number << ".\n";
  }
  return 0;
}


Output:

The hexadecimal number ffff is 65535.

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