Reputation: 1791
I would like to bind the third argument of the std::filesystem::copy, i.e.
void copy( const std::filesystem::path& from,
const std::filesystem::path& to,
std::filesystem::copy_options options );
to a certain value, say std::filesystem::copy_options::none.
When I do:
namespace fs = std::filesystem;
auto f1 = std::bind( fs::copy, _1, _2, fs::copy_options::none );
the gcc compiler (10.3.0, c++20) gives an error (see below): What am I doing wrong? Bertwim
> error: no matching function for call to ‘bind(<unresolved overloaded
> function type>, const std::_Placeholder<1>&, const
> std::_Placeholder<2>&, std::filesystem::copy_options)’ 641 |
> auto f2 = std::bind( fs::copy, std::placeholders::_1,
> std::placeholders::_2, fs::copy_options::none );
Upvotes: 1
Views: 122
Reputation: 180510
std::filesystem::copy
is an overloaded function. That means that it's name cannot decay into a single type since we don't know which overload you want. You could fix that with a cast but instead of doing that you can use a lambda expression to create your wrapper like
auto f1 = [](const auto& from, const auto& to) {
fs::copy(from, to, fs::copy_options::none);
};
Upvotes: 4