[Bug libstdc++/70564] New: Problem with std::experimental::not_fn
rcc.dark at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Apr 6 17:23:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70564
Bug ID: 70564
Summary: Problem with std::experimental::not_fn
Product: gcc
Version: 5.2.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: rcc.dark at gmail dot com
Target Milestone: ---
Hi all. The following code does not compile under MinGW-64 GCC 5.2.0 / Linux-64
GCC 5.3.1:
#include <experimental/functional>
#include <array>
int main( )
{
auto lambda = [](auto i) {
return i == 5;
};
std::array<int, 100> arr;
std::find_if(arr.begin( ), arr.end( ), std::experimental::not_fn(lambda));
}
Inside std::find_if, an object of the _Iter_Pred class is created:
_Iter_pred(_Predicate __pred)
: _M_pred(__pred)
{ }
which calls _Not_fn<PRED>(_Not_fn<PRED>&) since __pred is an lvalue. However,
between these _Not_fn constructors:
template<typename _Fn2>
explicit
_Not_fn(_Fn2&& __fn) : _M_fn(std::forward<_Fn2>(__fn)) { }
_Not_fn(const _Not_fn& __fn) = default;
_Not_fn(_Not_fn&& __fn) = default;
the first one wins and triggers an error.
More information about the Gcc-bugs
mailing list