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 6188225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:11:45+00:00 2026-05-24T02:11:45+00:00

In my program I would like to manipulate boost::filesystem::path elements of a vector in

  • 0

In my program I would like to manipulate boost::filesystem::path elements of a vector in a for loop.

typedef vector<fs::path> path_vec;
path_vec pv;

for (auto it = pv.cbegin(), end = pv.cend(); it != end; ++it)

What I would like to do is to add a string to the end of the path.

If I do it like this, it works fine:

stringstream image_file_0001;
image_file_0001 << it->string() << "/x_alpha0001.png";
p1 = image_file_0001.str();

If I do it like this, it works fine too:

string a = it->string();
string b = a.append("/prx");

But if I try to do it in one line

string c = it->string().append("/prx");

or

string d = (it->string()).append("/prx");

it gives compile errors:

7 overloads have no legal conversion for ‘this’ pointer

I think it must be my lack of knowledge about how to use pointers, or is it something to do with the boost::filesystem::path .string() function?

OK, the thing I would like to do is to create a directory with "/prx" appended to the origianl path in *it. Can I do it in one line?

boost::filesystem::createdirectory ( something here );

What seems to be my problem is that I don’t understand that why would .append() modify the original string. Isn’t it a function which returns an other string, which I can use freely, while just reading the original 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-05-24T02:11:47+00:00Added an answer on May 24, 2026 at 2:11 am

    fs::path.string() returns const& so you cannot append anything to it, first you need to make a copy

    but why do you do this at all? there’s a obvious way to append nested path:

    path / nested_path

    EDIT:

    typedef vector<fs::path> path_vec;
    path_vec pv;
    
    for (auto it = pv.begin(), end = pv.end(); it != end; ++it)
        *it /= "prx";
    

    or to create directories instead of modifying vector values, replace the last line by:

    fs::create_directory(*it / "prx");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to link 10 computers together, the program I would like to write
I have a program which I would like to run every X min the
I have a single user java program that I would like to have store
I currently have a small Java program which I would like to run both
I would like my program to update itself (downloading a new exe and/or some
I would like my program to email me a bug-report when it fails. Is
I would like to program a computer game which should be played by several
I would like to write a small program in C# which goes through my
I would like my GWT program to be able to determine whether it's in
I would like to write a program that will identify a machine( for licensing

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.