Recently I have taken a look at the implementation of std::not_fn
function template provided by gcc.
The return type of this function template is _Not_fn
- a wrapper class template which negates a wrapped callable object.
It turns out, that _Not_fn
constructor accepts an additional int
parameter which is not explicitly used:
template<typename _Fn2>
_Not_fn(_Fn2&& __fn, int)
: _M_fn(std::forward<_Fn2>(__fn)) { }
The call to the constructor looks like that:
template<typename _Fn>
inline auto not_fn(_Fn&& __fn)
noexcept(std::is_nothrow_constructible<std::decay_t<_Fn>, _Fn&&>::value)
{
return _Not_fn<std::decay_t<_Fn>>{std::forward<_Fn>(__fn), 0}; // <- 0 is passed here
}
Question:
What is the purpose of this additional int
parameter? Why does gcc implementation need it?