make FunctionRef constexpr on compilers that support it
authorEric Niebler <eniebler@fb.com>
Fri, 7 Jul 2017 23:31:31 +0000 (16:31 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 7 Jul 2017 23:35:42 +0000 (16:35 -0700)
commit81c9d2a6bd4e062b2fa68190175e3b20f566d2cb
tree734608ea42babd86852b2d84a36b58764218c0f4
parent7f15a179e20b0d61bfb5e872956993b0c6afaa30
make FunctionRef constexpr on compilers that support it

Summary:
`constexpr` All The Things! Although only very recent versions of modern compilers support this, FunctionRef can and should be `constexpr` (demonstration here: https://godbolt.org/g/NJ72RG).

This change also changes the `FunctionRef` constructor such that it no longer participates in overload resolution if the argument is not callable with the specified arguments. In addition, it perfectly forwards the callable object such that if it was an rvalue when it was passed to the constructor, it will be invoked as an rvalue in `operator()`.

Reviewed By: yfeldblum

Differential Revision: D5366720

fbshipit-source-id: bc64053213478aab5a5bd5950c7b2d6f364d86bd
folly/Function.h