Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unresolved overloaded function type for "fs::path::string"

Tags:

c++

boost

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
like image 380
Galaxy Avatar asked Dec 07 '25 07:12

Galaxy


2 Answers

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
    )
);
like image 198
nijansen Avatar answered Dec 08 '25 21:12

nijansen


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();
               }
);
like image 24
betabandido Avatar answered Dec 08 '25 19:12

betabandido



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!