I have redefined certain C++ function objects (STL functional) to provide constexpr operator() for them. I needed these functionals to get evaluated at compile time to use for template metaprogramming. C++14 provides constexpr equivalents for the STL functional library. Currently I am compiling code with C++11, but might eventually upgrade to C++14. How do I implement these such that if I upgrade to C++14, it would automatically pick the function objects from STL, rather than my custom implementation.
Here is how I have it so far:
namespace foo {
template <class T = void>
struct less {
constexpr bool operator()(T const& lhs, T const& rhs) const {
return lhs < rhs;
}
};
}
EDIT: I know this could be potentially done with __cplusplus
if I just alias my namespace with std. However that would be a bad solution since I would pollute the namespace foo for all other instances.