3
votes

boost 1.49 gcc version 4.6.3

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

How to edit this 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
2

2 Answers

6
votes

The answer can be found in the 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
    )
);
3
votes

If you can use C++11 (GCC 4.6 supports it using the flag -std=c++0x), then you can use a lambda function and it will become more readable:

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