Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
std::regex_...orm_primary(3)  C++ Standard Libary std::regex_...orm_primary(3)

NAME
       std::regex_traits::transform_primary	-    std::regex_traits::trans-
       form_primary

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

	  For  the  character sequence [first, last), obtains the primary sort
       key in the imbued
	  locale's collating order, that is, the sort key that is based	on the
       positions of
	  the letters and collation units in the national  alphabet,  ignoring
       case, diacritics,
	  variants, etc. If a primary sort key compares	less than another pri-
       mary sort key
	  with	operator<, then	the character sequence that produced the first
       sort key	comes
	  before the character sequence	that produced the second sort key,  in
       the currently
	  imbued locale's primary collation order.

	  The regex library uses this trait to match characters	against	equiv-
       alence classes.
	  For example, the regex [[=a=]] is equivalent to the character	c1 if
	  traits.transform_primary(c1)	is equivalent to traits.transform_pri-
       mary("a") (which
	  is true for any c1 from "A a " in the	U.S. English locale).
	  Note that transform_primary()	takes a	 character  sequence  argument
       because
	  equivalence classes may be multicharacter, such as [[=ch=]] in Czech
       or [[=dzs=]] in
	  Hungarian.

	  There	 is  no	 portable  way	to define primary sort key in terms of
       std::locale since
	  the  conversion  from	 the  collation	 key  returned	by   std::col-
       late::transform() to the
	  primary equivalence key is locale-specific, and if the user replaces
       the
	  std::collate	facet, that conversion is no longer known to the stan-
       dard library's
	  std::regex_traits.	Standard    library	specializations	    of
       std::regex_traits return	an
	  empty	 string	 unless	the std::collate facet of the currently-imbued
       locale was not
	  replaced  by	the  user,  and	 still	matches	 the   system-supplied
       std::collate facet), in
	  which	case std::collate_byname<charT>::transform(first, last)	is ex-
       ecuted and the
	  sort	key  it	produces is converted to the expected primary sort key
       using a
	  locale-specific conversion.

Parameters
	  first, last -	a pair of iterators which determines the  sequence  of
       characters to
			compare

Type requirements
	  -
	  ForwardIt must meet the requirements of LegacyForwardIterator.

Return value
	  The primary sort key for the character sequence [first, last)	in the
       currently
	  imbued locale, ignoring case,	variant, diacritics, etc.

Example
	  Demonstrates	the  regex  feature  that works	through	transform_pri-
       mary()

       // Run this code

	#include <iostream>
	#include <regex>

	int main()
	{
	    std::locale::global(std::locale("en_US.UTF-8"));
	    std::wstring str = L"Aa ";
	    std::wregex	re(L"[[=a=]]*",	std::regex::basic);
	    std::cout << std::boolalpha	<< std::regex_match(str, re) <<	'\n';
	}

Output:
	true

	   This	section	is incomplete
	   Reason: could use an	example	with user-defined regex_traits supply-
       ing user-defined
	   transform_primary

http://cppreference.com		  2022.07.31	  std::regex_...orm_primary(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::regex_traits::transform_primary&sektion=3&manpath=FreeBSD+Ports+15.0>

home | help