I want to make an equivalent to boost::swap
and in my environment, standard headers can, or cannot be included. Depending on project licencing and other stuff.
I'd like to make portions of the code protected by guard detectors:
Let's consider one compilation unit.
project specific, afore-written potential includes:
#include <algorithm> // (or <utility> for C++11 projects)
later in project code included from my swap utility header:
namespace MyCompany
{
template<class T1, class T2>
void swap(T1& left, T2& right)
{
#ifdef _ALGORITHM_ // you get the idea.
std::swap(left, right);
#else
// fallback impl
#endif
}
}
I simplified because we are not talking about details of the ADL trick here, but it will get included.
here for the reference of what I am talking about, but this is irrelevant to this question:
http://www.boost.org/doc/libs/1_57_0/boost/core/swap.hpp
So this question is about, how can I detect standard header inclusion ? the _ALGORITHM_
guard is present in visual studio provided header, but I read nowhere on http://www.cplusplus.com/reference/algorithm/ that it should have any macro that I can check.
(final note: this question is a little bit XY biased. What I really want is to detect the presence of the std::swap
function, not the header.)