[Boost] boost: string_algo 4 -- trim_if, trim_copy_if, trim_xxxx_if, trim_xxxx_copy_if

Source: Internet
Author: User

Partial function prototype

template<typename SequenceT, typename PredicateT>  void trim_if(SequenceT & Input, PredicateT IsSpace);template<typename OutputIteratorT, typename RangeT, typename PredicateT>  OutputIteratorT    trim_copy_if(OutputIteratorT Output, const RangeT & Input,                                 PredicateT IsSpace);template<typename SequenceT, typename PredicateT>  SequenceT     trim_copy_if(const SequenceT & Input, PredicateT IsSpace);template<typename SequenceT, typename PredicateT>  void trim_left_if(SequenceT & Input, PredicateT IsSpace);template<typename OutputIteratorT, typename RangeT, typename PredicateT>  OutputIteratorT    trim_left_copy_if(OutputIteratorT Output, const RangeT & Input,                      PredicateT IsSpace);template<typename SequenceT, typename PredicateT>  SequenceT    trim_left_copy_if(const SequenceT & Input, PredicateT IsSpace);

Example

Void test_string_trim_if () {STD: String STR = "ABCD! @ # $ % ^ Efghi1234xyz "; STD: String str1 = boost: trim_left_copy_if (STR, boost: is_alnum (); Assert (str1 = "! @ # $ % ^ Efghi1234xyz "); STD: String str2 = boost: trim_right_copy_if (STR, boost: is_alnum (); Assert (str2 =" ABCD! @ # $ % ^ "); STD: String str3 = boost: trim_copy_if (STR, boost: is_alnum (); Assert (str3 = "! @ # $ % ^ "); Boost: trim_left_if (STR, boost: is_alnum (); Assert (STR = "! @ # $ % ^ Efghi1234xyz "); Boost: trim_right_if (STR, boost: is_alnum (); Assert (STR = "! @ # $ % ^ "); // If it is a binary function, you can handle STD: String str2nd (" ### goodbye Chongqing! ###### "); Boost: trim_if (str2nd, bind2nd (STD: equal_to <char> (),'#')); assert (str2nd = "Goodbye Chongqing! "); // Of course, you can use the following method to implement the above function STD: String strany (" ### Hello Fuzhou! ###### "); Boost: trim_if (strany, boost: is_any_of (" # "); Assert (strany =" Hello Fuzhou! ");}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.