This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/70564] New: Problem with std::experimental::not_fn
- From: "rcc.dark at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 06 Apr 2016 17:22:55 +0000
- Subject: [Bug libstdc++/70564] New: Problem with std::experimental::not_fn
- Auto-submitted: auto-generated
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.