std::regex_..._collatename(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

✨ NAME ✨

std::regex_traits::lookup_collatename β€” std::regex_traits::lookup_collatename

okay so this is the std::regex_..._collatename(3) page from the C++ Standard Libary, and bestie, it’s literally all about std::regex_traits::lookup_collatename. 🫢

🌸 Synopsis 🌸

template< class ForwardIt >
string_type lookup_collatename( ForwardIt first, ForwardIt last )
const;

If the character sequence [first, last) represents the name of a valid collating element in the currently imbued locale, it returns the name of that collating element. Otherwise, it returns an empty string. No cap. ✨

Collating elements are the symbols found in POSIX regular expressions between [. and .]. For example, [.a.] matches the character a in the C locale. [.tilde.] matches the character ~ in the C locale as well. [.ch.] matches the digraph ch in Czech locale, but generates std::regex_error with error code std::regex_constants::error_collate in most other locales. It’s giving very specific locale behavior. πŸ’…

🌈 Parameters 🌈

  • first, last β€” a pair of iterators which determines the sequence of characters that represents a collating element name. that’s the whole parameter moment.

πŸ¦‹ Type requirements πŸ¦‹

  • ForwardIt must meet the requirements of LegacyForwardIterator. periodt.

πŸ‘‘ Return value πŸ‘‘

The representation of the named collating element as a character string. slay.

πŸŽ€ Example πŸŽ€

Run this code, bestie (// Run this code energy): ✨

#include <iostream>
#include <regex>
#include <string>

struct noisy_traits : std::regex_traits<char>
{
    template<class Iter>
    string_type lookup_collatename(Iter first, Iter last) const
    {
        string_type result = regex_traits::lookup_collatename(first, last);
        std::cout << "regex_traits<>::lookup_collatename(\""
                  << string_type(first, last)
                  << "\") returns \"" << result << "\"\n";
        return result;
    }
};

int main()
{
    std::string str = "z|}a"; // C locale collation order: x,y,z,{,|,},~
    std::basic_regex<char, noisy_traits> re("[x-[.tilde.]]*a", std::regex::basic);
    std::cout << std::boolalpha << std::regex_match(str, re) << '\n';
}

πŸ“ Possible output: πŸ“

regex_traits<>::lookup_collatename("tilde") returns "~"
true

that’s the possible output, fr fr. πŸ’–


mwah πŸ’‹ source is http://cppreference.com, version/date is 2024.06.10, and the page is std::regex_..._collatename(3). bye bestie πŸ’–

πŸ“¦ where this page comes from