2011/7/19 Eric Lin <kingdavid1@w.cn>

Dear Advanced c/g++ on boost programers:

  I have copied and testd a simple (Copy a file with Boost) program from page 372, Example10-10, book(C++ cookbook)
but I got compile error
-----------------------------
eric@eric-laptop:~/cppcookbook/ch10$ g++ Example10-10.cpp
Example10-10.cpp: In function ‘int main(int, char**)’:
Example10-10.cpp:17:47: error: invalid conversion from ‘bool (*)(const std::string&)’ to ‘boost::enable_if_c<true, void>::type*’
Example10-10.cpp:17:47: error:   initializing argument 2 of ‘boost::filesystem3::path::path(const Source&, typename boost::enable_if<boost::filesystem3::path_traits::is_pathable<typename boost::decay<Source>::type> >::type*) [with Source = char*, typename boost::enable_if<boost::filesystem3::path_traits::is_pathable<typename boost::decay<Source>::type> >::type = void]’
Example10-10.cpp:18:47: error: invalid conversion from ‘bool (*)(const std::string&)’ to ‘boost::enable_if_c<true, void>::type*’
Example10-10.cpp:18:47: error:   initializing argument 2 of ‘boost::filesystem3::path::path(const Source&, typename boost::enable_if<boost::filesystem3::path_traits::is_pathable<typename boost::decay<Source>::type> >::type*) [with Source = char*, typename boost::enable_if<boost::filesystem3::path_traits::is_pathable<typename boost::decay<Source>::type> >::type = void]’
Example10-10.cpp:18:48: error: expected ‘)’ before ‘;’ token
-----------------------------
This is my program, you can download and test by your self from
http://examples.oreilly.com/9780596007614/
-----------------------------------------------------
// Example 10-10.  Copying a file with Boost
#include <iostream>
#include <string>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/path.hpp>

using namespace std;
using namespace boost::filesystem;

int main(int argc, char** argv) {

   // Parameter checking...

   try {
      // Turn the args into absolute paths using native formatting
      path src = complete(path(argv[1], native));
      path dst = complete(path(argv[2], native);
      copy_file(src, dst);
   }
   catch (exception& e) {
     cerr << e.what() << endl;
   }
  
   return(EXIT_SUCCESS);
}
----------------------------------------------------------------------------
I ever check around web, there is some suggestion ask me to get rid native, but in my test/system, it only
generate more errors.
my boost version probably is 1.46.1
and I am on g++ 4.5.2 and Ubuntu10.04/linuxKernel2.6.35-25
Need and thanks your help a lot in advance, Eric

Removing the "native" does work well for me, what are the errors you saw then?
Link errors? You must link against the boost filesystem & system lib.