std::unary_function is still present in C++17

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

std::unary_function is still present in C++17

Fredrik Hellman
Hi,

I am surprised to see that std::unary_function is still defined when
including "functional" and compiling for C++17. It appears to be defined in
bits/stl_function.h where it is defined regardless of C++ version.

This gives me a bit of portability problems, since I get no indication from
the library that it is removed and might not compile on other platforms.
For instance, the class has been removed in MSVC.

Is there some way for me to keep the compiler/library to stick more
pedantically to the standard?

Best regards,
Fredrik Hellman
Reply | Threaded
Open this post in threaded view
|

Re: std::unary_function is still present in C++17

Jonathan Wakely-4
On Mon, 11 Nov 2019 at 10:20, Fredrik Hellman wrote:
>
> Hi,
>
> I am surprised to see that std::unary_function is still defined when
> including "functional" and compiling for C++17. It appears to be defined in
> bits/stl_function.h where it is defined regardless of C++ version.

Yes, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91260

> This gives me a bit of portability problems, since I get no indication from
> the library that it is removed and might not compile on other platforms.
> For instance, the class has been removed in MSVC.
>
> Is there some way for me to keep the compiler/library to stick more
> pedantically to the standard?

Pedantically speaking, the standard allows us to define them. It also
allows us to remove them.

It's not a goal of libstdc++ to be a conformance checker to ensure
your code is portable.