The std::unary_function feature was deprecated in c++11 and deleted in c++17. But with the c++17 compiler flag, this code still compiles:
struct less_than_7 : std::unary_function<int, bool>
{
bool operator()(int i) const { return i < 7; }
};
Built with g++ -std=c++17 -O0 -Wall -pedantic main.cpp here.
Is a feature deletion optional for a compiler to implement?
Since it's no longer part of the C++17 standard its inclusion in one of your source code files falls into the same category as code that introduces things into std.
In other words, the program behaviour is undefined.
The program working is a manifestation of that undefined behaviour. And perhaps your implementation defines that undefined behaviour. But even so, your code is not portable C++17.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With