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

  • SEARCH
  • Home
  • 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 8528917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:54:36+00:00 2026-06-11T08:54:36+00:00

Hi I have vector of strings,that is the structure of vector : The name

  • 0

Hi I have vector of strings,that is the structure of vector : The name of vector is vector

"key:  abc 165.123.34.12", 
"key:  bca 1.1.1.1", 
"key1: bac 3.3.3.3"

I want to sort the vector according to the second field(abc,bac,bac)

My code is;

 bool sort_function(string& str1,string& str2) {

     string nick1,nick2,nick1_ignore,nick2_ignore;

     stringstream ss1(str1) 

     ss1>> nick1_ignore >> nick1;

     stringstream ss2(str2) 

     ss2>> nick2_ignore >> nick2;

     return (nick1<nick2);

 }


     sort(vector.begin(), vector.end(),sort_function);

But it gives a long error starting with error,

  error: no match for ‘operator>>’ in ‘std::basic_stringstream<char>

UPDATE:Error is tl_algo.h: In function ‘_RandomAccessIterator std:..

UPDATE:It is fixed. the error is in function declaration I have to use const string

  • 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-06-11T08:54:38+00:00Added an answer on June 11, 2026 at 8:54 am

    The function template overload operator>>(std::basic_istream &, std::string &) is non-const on its istream parameter, so you can’t call it on a temporary.

    This is confusing, because you can call the member operator>> when reading a primitive e.g. int.

    Instead, you’ll have to write

    stringstream ss1(str1); ss1 >> nick1_ignore >> nick1;
    

    You could also work around this by first reading a no-op manipulator or calling a no-op method to get an lvalue reference:

    stringstream(str1).ignore(0) >> nick1_ignore >> nick1;
    

    C++11 fixes this by providing overloads of the free operator>> with the istream parameter an rvalue reference.

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

Sidebar

Related Questions

I have a std::vector<uint8_t> that contains strings at specific offsets. Here's a shortened dump:
I have vector of strings and want to create a fixed with string out
I have a vector of strings that i read from the output of a
I have a vector x of 1,344 unique strings. I want to generate a
I have a vector x of 1,344 unique strings. I want to generate a
I want to create a structure that holds distinct strings and assign to each
I have a vector of strings that contain numbers, words, spaces, and even weird
I have an instance method that populates a vector of strings. I am trying
I have a vector of strings which are changing its contents for no apparent
I have some data structures: all_unordered_m is a big vector containing all the strings

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.