Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7546579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:14:07+00:00 2026-05-30T09:14:07+00:00

There is a very useful function in Python called strip() . Any similar ones

  • 0

There is a very useful function in Python called strip(). Any similar ones in C++?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T09:14:10+00:00Added an answer on May 30, 2026 at 9:14 am

    There’s nothing built-in; I used to use something like the following:

    template <std::ctype_base::mask mask>
    class IsNot
    {
        std::locale myLocale;       // To ensure lifetime of facet...
        std::ctype<char> const* myCType;
    public:
        IsNot( std::locale const& l = std::locale() )
            : myLocale( l )
            , myCType( &std::use_facet<std::ctype<char> >( l ) )
        {
        }
        bool operator()( char ch ) const
        {
            return ! myCType->is( mask, ch );
        }
    };
    
    typedef IsNot<std::ctype_base::space> IsNotSpace;
    
    std::string
    trim( std::string const& original )
    {
        std::string::const_iterator right = std::find_if( original.rbegin(), original.rend(), IsNotSpace() ).base();
        std::string::const_iterator left = std::find_if(original.begin(), right, IsNotSpace() );
        return std::string( left, right );
    }
    

    which works pretty well. (I now have a significantly more complex
    version which handles UTF-8 correctly.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Are there any c++ networking libs that are very useful and robust? and libs
In PostgreSQL, there is this very useful string_agg function, that allows query like: SELECT
There are some very useful classes for working with images. I am stuck with
I'm working with the very-useful ID3 framework in my cocoa project. There's one tiny
This is something that I think would be very useful. Basically, I'd like there
There is a very useful Clips feature in Coda, does Eclipse have such feature?
On Mac OS X there is a very useful open command which launches an
In Linux (Bash) there is a very useful functionality for dumping literal text out
Is there any centralized repository of useful Objective-C / Cocoa libraries as there is
sys.dm_exec_query_stats seems to be a very useful function to gather statistics from your database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.