Talk:cpp/named req/FunctionObject
From cppreference.com
[edit] Standard Library
unique_ptr requires a FunctionObject which isn't Callable? huh? Jwakely (talk) 08:05, 22 November 2014 (PST)
- That's from 20.8.1.2[unique.ptr.single]p1 "A client-supplied template argument D shall be a function object type (20.9), ...". This page describes the function object type as defined by 20.9. Can you use a pointer to data member as a deleter? --Cubbi (talk) 11:10, 22 November 2014 (PST)
[edit] Is operator() required to be const?
This page suggests that the following is not a function object type, because one cannot evaluate "f()" when f has type "const T":
class T { void operator()() {} };
I don't immediately see such a restriction in the definition given in 20.14.1 of this C++20 draft, but I'm not a standard guru so I could well be missing it elsewhere.
I'm currently using a class with non-const operator() as a deleter for std::unique_ptr and would like to know if that's conformant.