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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:00:01+00:00 2026-06-11T14:00:01+00:00

I have the following code: boost::filesystem::path p = boost::filesystem::current_path(); But I get this error

  • 0

I have the following code:

boost::filesystem::path p = boost::filesystem::current_path();

But I get this error from g++:

filesystem.cc: In function ‘int main(int, char**)’:
filesystem.cc:11: error: no matching function for call to ‘current_path()’
/usr/include/boost/filesystem/operations.hpp:769: note: candidates are: void boost::filesystem::current_path(const boost::filesystem::path&)
/usr/include/boost/filesystem/operations.hpp:771: note:                 void boost::filesystem::current_path(const boost::filesystem::wpath&)

In /usr/include/boost/filesystem/operations.hpp, I have the following:

template< class Path >
Path current_path()
{
  typename Path::external_string_type ph;
  system::error_code ec( detail::get_current_path_api( ph ) );
  if ( ec )
      boost::throw_exception( basic_filesystem_error<Path>(
        "boost::filesystem::current_path", ec ) );
  return Path( Path::traits_type::to_internal( ph ) );
}

So the function is there. I’m using it just like the examples in the boost documentation. Is there something stupid I’m missing here? If I make a path with “.”, it works, but I want the full pathname, not just “.”.

I have g++ 4.4.6 on RedHat enterprise 6.2, with boost 1.41.0 (I know it’s old, but I don’t have the option of upgrading).

  • 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-11T14:00:03+00:00Added an answer on June 11, 2026 at 2:00 pm

    Looking at the definition of current_path…

    template< class Path > Path current_path() ...

    • current_path is a function template, and the template argument type can’t be inferred from its parameters (of which there are none) – so we have to explicitly provide the template argument.
    • the return type of current_path() has the same type as the template argument.

    The reason for this is so we can return narrow and wide character paths ie:

    namespace fs = boost::filesystem;
    
    // get the current path    
    fs::path p = fs::current_path<fs::path>();
    
    // get the current path in wide characters    
    fs::wpath wp = fs::current_path<fs::wpath>();
    

    wpath is the wide character version of path (akin to wstring and string).

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

Sidebar

Related Questions

I have following code: #include <cstring> #include <boost/functional/hash.hpp> #include <iostream> int main(int argc, char
I have the following code: #include <boost/shared_ptr.hpp> struct Foo { int a; }; static
I have the following code, in which Boost.Local uses a function callback to load
I have the following code which i m trying to compile: #include <boost/filesystem/convenience.hpp> #include
I'm trying to compile the following snippet of code: #include <boost/filesystem/path.hpp> //Other includes snipped
I have the following code: #include <string> #include <boost/thread/tss.hpp> static boost::thread_specific_ptr<string> _tssThreadNameSptr; I get
I have the following code, and although the call to boost::filesystem::create_directory returns true ,
I have written the following code #include <iostream> #include <boost/asio.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/filesystem.hpp>
I have the following class using boost filesystem, but encountered the problem when compiling.
I have the following code: #include <iostream> #define BOOST_TEST_MODULE my test #include <boost/test/unit_test.hpp> BOOST_AUTO_TEST_CASE(

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.