1

std::function<int(float)>: in here int(float) is a function type that returns an int and accepts (as an argument) float.

What I'm trying to understand

  • std::function<int(float) const>
  • std::function<int(float) const&>

What is the meaning of the const and const& in the above statements

Thank you

SlyBits
  • 31
  • 2
  • Is that valid? Fascinating! I think the first refers to a function that doesn't modify the function(oid), but I'm struggling to understand the latter one. – Mooing Duck Jun 08 '20 at 19:37
  • 1
    @MooingDuck It's not valid. Per C++17 [func.wrap.func] the template `std::function` is only defined when `T` is of the form `R(ArgTypes...)` – Brian Bi Jun 08 '20 at 19:44
  • That's a little sad. That means you can't guarantee a reseatable `std::function<...>` to a non-mutable functionoid. – Mooing Duck Jun 08 '20 at 19:52

0 Answers0