If there a way to test a char to a class of user define character?

Is there any way to define a type and do the following?

char c = 'a';
if (c == BRASSECHARTYPE)
{
     // do something if c is one of the following char [{()}]
}

Answer

There is lots of ways to do it:

Simple function:

bool isOneOfChars(char ch, std::initializer_list<char> chars)
{
    return std::find(std::begin(chars), std::end(chars), ch) != std::end(chars);
}

bool isBrace(char ch)
{
    return isOneOfChars(ch, {'[', '{', '(', ')', '}'});
}

Fancy template with fold expression:

template<char...Chars>
constexpr bool isOneOfChars(char ch)
{
    return ((Chars == ch) || ...);
}

constexpr bool isBrace(char ch)
{
     return isOneOfChars<'[', '{', '(', ')', '}'>(ch);
}

Or lookup table with designated initializes (clangs supports it):

constexpr bool isBrace(char ch)
{
    constexpr bool braceTable[256] {
        ['['] = true, 
        ['{'] = true, 
        ['('] = true, 
        [')'] = true, 
        ['}'] = true,
    };

    return braceTable[static_cast<unsigned char>(ch)];
}

or any other solution.

https://godbolt.org/z/beGzq4snM