Loading...
Searching...
No Matches
Builtin Character Operations
Utility

Provides various operations on character types. More...

Collaboration diagram for Builtin Character Operations:

## Char predicates

A set of function objects to check if a character from an input source fulfills certain characteristics.
template<uint8_t interval_first, uint8_t interval_last>
constexpr auto | seqan3::is_in_interval
| Checks whether a given letter is in the specified interval.
template<int char_v>
constexpr auto | seqan3::is_char
| Checks whether a given letter is the same as the template non-type argument.
constexpr auto | seqan3::is_cntrl = is_in_interval<'\0', static_cast<char>(31)> || is_char<static_cast<char>(127)>
| Checks whether c is a control character.
constexpr auto | seqan3::is_print = is_in_interval<' ', '~'>
| Checks whether c is a printable character.
constexpr auto | seqan3::is_space = is_in_interval<'\t', '\r'> || is_char<' '>
| Checks whether c is a space character.
constexpr auto | seqan3::is_blank = is_char<'\t'> || is_char<' '>
| Checks whether c is a blank character.
constexpr auto | seqan3::is_alpha = is_in_interval<'A', 'Z'> || is_in_interval<'a', 'z'>
| Checks whether c is a graphic character.
constexpr auto | seqan3::is_upper = is_in_interval<'A', 'Z'>
| Checks whether c is a upper case character.
constexpr auto | seqan3::is_lower = is_in_interval<'a', 'z'>
| Checks whether c is a lower case character.
constexpr auto | seqan3::is_digit = is_in_interval<'0', '9'>
| Checks whether c is a digital character.
constexpr auto | seqan3::is_xdigit = is_in_interval<'0', '9'> || is_in_interval<'A', 'F'> || is_in_interval<'a', 'f'>
| Checks whether c is a hexadecimal character.
constexpr auto | seqan3::is_eof = is_char<EOF>
| Checks whether a given letter is equal to the EOF constant defined in <cstdio>.

## Detailed Description

Provides various operations on character types.

See also
  Utility

## Variable Documentation

## is_alpha

auto seqan3::is_alpha = is_in_interval<'A', 'Z'> || is_in_interval<'a', 'z'>

inline constexpr

Checks whether c is a graphic character.

This function like object can be used to check if a character c is a graphic (has a graphical representation) character. For the standard ASCII character set, the following characters are graphic characters:

- digits (0123456789)
- uppercase letters (ABCDEFGHIJKLMNOPQRSTUVWXYZ)
- lowercase letters (abcdefghijklmnopqrstuvwxyz)
- punctuation characters (!"#$%&'()*+,-./:;<=>?@[]^_`{|}~)

### Example

static_assert(seqan3::is_graph('%'));

*/ inline constexpr auto is_graph = is_in_interval<'!', '~'>;

/*! Checks whether c is a punctuation character.

This function like object can be used to check if a character c is a punctuation character. For the standard ASCII character set, the following characters are punctuation characters:

- punctuation characters (!"#$%&'()*+,-./:;<=>?@[]^_`{|}~)

### Example

static_assert(seqan3::is_punct(':'));

*/ inline constexpr auto is_punct = is_in_interval<'!', '/'> || is_in_interval<':', '@'> || is_in_interval<'[', '`'> || is_in_interval<'{', '~'>;

/*! Checks whether c is a alphanumeric character.

This function like object can be used to check if a character c is a alphanumeric character. For the standard ASCII character set, the following characters are alphanumeric characters:

- digits (0123456789)
- uppercase letters (ABCDEFGHIJKLMNOPQRSTUVWXYZ)
- lowercase letters (abcdefghijklmnopqrstuvwxyz)

### Example

static_assert(seqan3::is_alnum('9'));

*/ inline constexpr auto is_alnum = is_in_interval<'0', '9'> || is_in_interval<'A', 'Z'> || is_in_interval<'a', 'z'>;

/*! Checks whether c is a alphabetical character.

This function like object can be used to check if a character c is a alphabetical character. For the standard ASCII character set, the following characters are alphabetical characters:

- uppercase letters (ABCDEFGHIJKLMNOPQRSTUVWXYZ)
- lowercase letters (abcdefghijklmnopqrstuvwxyz)

### Example

static_assert(seqan3::is_alpha('z'));

## is_blank

auto seqan3::is_blank = is_char<'\t'> || is_char<' '>

inline constexpr

Checks whether c is a blank character.

This function like object can be used to check if a character c is a blank character. For the standard ASCII character set, the following characters are blank characters:

- horizontal tab ('\t')
- space (' ')

### Example

static_assert(seqan3::is_blank('\t'));

## is_char

template<int char_v>

auto seqan3::is_char

inline constexpr

Checks whether a given letter is the same as the template non-type argument.

Template Parameters

  char_v | The letter to compare against.

This function like object returns true if the argument is the same as the template argument, false otherwise.

### Example

// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <seqan3/utility/char_operations/predicate.hpp>
int main()
{
seqan3::is_char<'C'>('C'); // returns true
constexpr auto my_check = seqan3::is_char<'C'>;
my_check('c'); // returns false, because case is different
}
seqan3::is_char
constexpr auto is_char
Checks whether a given letter is the same as the template non-type argument.
Definition predicate.hpp:60
predicate.hpp
Provides character predicates for tokenisation.

## is_cntrl

auto seqan3::is_cntrl = is_in_interval<'\0', static_cast<char>(31)> || is_char<static_cast<char>(127)>

inline constexpr

Checks whether c is a control character.

This function like object can be used to check if a character c is a control character. For the standard ASCII character set, control characters are those between ASCII codes 0x00 (NUL) and 0x1f (US) and 0x7f (DEL).

### Example

static_assert(seqan3::is_cntrl('\0'));

## is_digit

auto seqan3::is_digit = is_in_interval<'0', '9'>

inline constexpr

Checks whether c is a digital character.

This function like object can be used to check if a character c is a digital character. For the standard ASCII character set, the following characters are digital characters:

- digits (0123456789)

### Example

static_assert(seqan3::is_digit('1'));

## is_eof

auto seqan3::is_eof = is_char<EOF>

inline constexpr

Checks whether a given letter is equal to the EOF constant defined in <cstdio>.

This function like object returns true if the argument is equal to EOF, false otherwise.

### Example

static_assert(seqan3::is_eof(EOF));
static_assert(!seqan3::is_eof('C'));

## is_in_interval

template<uint8_t interval_first, uint8_t interval_last>

auto seqan3::is_in_interval

inline constexpr

Checks whether a given letter is in the specified interval.

Template Parameters

  interval_first | The first character for which to return true.
  interval_last | The last character (inclusive) for which to return true.

This function like object returns true for all characters in the given range, false otherwise.

### Example

// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <seqan3/utility/char_operations/predicate.hpp>
int main()
{
seqan3::is_in_interval<'A', 'G'>('C'); // returns true
constexpr auto my_check = seqan3::is_in_interval<'A', 'G'>;
my_check('H'); // returns false
}
seqan3::is_in_interval
constexpr auto is_in_interval
Checks whether a given letter is in the specified interval.
Definition predicate.hpp:44

## is_lower

auto seqan3::is_lower = is_in_interval<'a', 'z'>

inline constexpr

Checks whether c is a lower case character.

This function like object can be used to check if a character c is a lower case character. For the standard ASCII character set, the following characters are lower case characters:

- lowercase letters (abcdefghijklmnopqrstuvwxyz)

### Example

static_assert(seqan3::is_lower('a'));

## is_print

auto seqan3::is_print = is_in_interval<' ', '~'>

inline constexpr

Checks whether c is a printable character.

This function like object can be used to check if a character c is a printable character. For the standard ASCII character set, printable characters are those between ASCII codes 0x20 (space) and 0x7E (~).

### Example

static_assert(seqan3::is_print(' '));

## is_space

auto seqan3::is_space = is_in_interval<'\t', '\r'> || is_char<' '>

inline constexpr

Checks whether c is a space character.

This function like object can be used to check if a character c is a space character. For the standard ASCII character set, the following characters are space characters:

- horizontal tab ('\t')
- line feed ('\n')
- vertical tab ('\v')
- from feed ('\f')
- carriage return ('\r')
- space (' ')

### Example

static_assert(seqan3::is_space('\n'));

## is_upper

auto seqan3::is_upper = is_in_interval<'A', 'Z'>

inline constexpr

Checks whether c is a upper case character.

This function like object can be used to check if a character c is a upper case character. For the standard ASCII character set, the following characters are upper case characters:

- uppercase letters (ABCDEFGHIJKLMNOPQRSTUVWXYZ)

### Example

static_assert(seqan3::is_upper('K'));

## is_xdigit

auto seqan3::is_xdigit = is_in_interval<'0', '9'> || is_in_interval<'A', 'F'> || is_in_interval<'a', 'f'>

inline constexpr

Checks whether c is a hexadecimal character.

This function like object can be used to check if a character c is a hexadecimal character. For the standard ASCII character set, the following characters are hexadecimal characters:

- digits (0123456789)
- uppercase letters (ABCDEF)
- lowercase letters (abcdef)

### Example

static_assert(seqan3::is_xdigit('e'));
Hide me