gul-cpp / gul14

General Utility Library for C++14
https://gul14.info/
GNU Lesser General Public License v2.1
2 stars 1 forks source link

Fix compilation errors in gul14::variant when compiled with C++17 #48

Closed alt-graph closed 1 year ago

alt-graph commented 1 year ago

As reported by Sören, when compiled with a C++17 compiler, gul14::variant causes a compilation error related to invoke_result_t. This error does not occur when compiled under C++14.

The bug seems to be subtle. Instead of fixing it directly, we can take advantage of the fact that the various invoke functions and types

invoke
invoke_result
invoke_result_t
is_invocable
is_invocable_r

are already available in namespace std on a C++17 compiler. Hence, we add a conditional compilation section that simply uses the following declarations on C++17 instead of the home-brew ones:

using std::invoke;
using std::invoke_result;
using std::invoke_result_t;
using std::is_invocable;
using std::is_invocable_r;