2012-05-31 3 views
3

boost 1,49 version gcc 4.6.3type de fonction non résolue surcharge pour "fs :: chemin :: string"

 std::transform(barcodeFiles.begin(), barcodeFiles.end(), std::ostream_iterator<std::string>(std::cerr, "\n"), 
      boost::bind(&fs::path::string, _1)); 

Comment modifier ce code?

 
[ 65%] Building CXX object c++/lib/demultiplex/CMakeFiles/casava_demultiplex.dir/BclDemultiplexer.cpp.o 
/bak/software/Linux/CASAVA_v1.8.2/src/c++/lib/demultiplex/BclDemultiplexer.cpp: In member function ‘const casava::demultiplex::BclDemultiplexer::ClusterCorrectedBarcodeIndex casava::demultiplex::BclDemultiplexer::mapClusterBarcodes(unsigned int) const’: 
/bak/software/Linux/CASAVA_v1.8.2/src/c++/lib/demultiplex/BclDemultiplexer.cpp:65:50: error: no matching function for call to ‘bind(, boost::arg&)’ 
/bak/software/Linux/CASAVA_v1.8.2/src/c++/lib/demultiplex/BclDemultiplexer.cpp:65:50 

Répondre

3

Si vous pouvez utiliser C++ 11 (GCC 4.6 prend en charge à l'aide de l'indicateur std = C++ 0x), vous pouvez utiliser une fonction lambda et il deviendra plus lisible:

std::transform(barcodeFiles.begin(), barcodeFiles.end(), 
       std::ostream_iterator<std::string>(std::cerr, "\n"), 
       [](const fs::path& p) { 
        return p.string(); 
       } 
); 
6

La réponse se trouve dans le FAQ of boost bind

std::transform(
    paths.begin(), paths.end(), 
    std::ostream_iterator<std::string>(
     std::cerr, "\n" 
    ), 
    boost::bind(
     static_cast< 
      std::string const & (boost::filesystem::path::*)() const 
     >(&boost::filesystem::path::string), 
     _1 
    ) 
); 
+0

oublié un '' et 'à static_cast nijansen

Questions connexes