This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/65942] [5/6 Regression] [C++14] cannot use std::function as comparator in algorithms
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 30 Apr 2015 09:32:19 +0000
- Subject: [Bug c++/65942] [5/6 Regression] [C++14] cannot use std::function as comparator in algorithms
- Auto-submitted: auto-generated
- References: <bug-65942-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65942
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|libstdc++ |c++
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This seems to be a compiler bug not a library bug:
#include <functional>
bool cmp1(const int& a, const int& b) { return a < b; }
std::function<bool (const int&, const int&)> cmp2 = cmp1;
template<typename _Compare>
struct _Iter_comp_iter
{
_Compare _M_comp;
_Iter_comp_iter(_Compare __comp)
: _M_comp(__comp)
{ }
template<typename _Iterator1, typename _Iterator2>
#if __cplusplus >= 201402L
constexpr
#endif
bool
operator()(_Iterator1 __it1, _Iterator2 __it2)
{ return bool(_M_comp(*__it1, *__it2)); }
};
template<typename _Compare>
inline _Iter_comp_iter<_Compare>
__iter_comp_iter(_Compare __comp)
{ return _Iter_comp_iter<_Compare>(__comp); }
int main() {
int v[1];
int* iter = v;
auto cmp = __iter_comp_iter(cmp2);
cmp(iter, iter);
}