#include <iostream>
#include <functional> // needed for std::equal_to
#include <iterator>
using namespace std;
namespace
{
using namespace std;
/**
* LIFTED -@todo add docs/reference
* from Stroustrup C++11 book - page 800
*/
struct substitution_failure
{
};
/**
* LIFTED -@todo add docs/reference
* from Stroustrup C++11 book - page 800
*/
template < typename T > struct substitution_succeeded:true_type
{
};
template <> struct substitution_succeeded <substitution_failure >:false_type
{
};
#define STROIKA_FOUNDATION_CONFIGURATION_DEFINE_HAS(NAME, XTEST) \
namespace Private_ { \
template <typename T> \
struct NAME##_result_impl { \
template <typename X> \
static auto check (const X& x) -> decltype (XTEST); \
static substitution_failure check (...); \
using type = decltype (check (declval<T> ())); \
}; \
} \
template <typename T> \
using NAME##_result = typename Private_::NAME##_result_impl<T>::type; \
template <typename T> \
struct has_##NAME : integral_constant<bool, not is_same<NAME##_result<T>, substitution_failure>::value> { \
}; \
template <typename ITERABLE> \
constexpr bool Has##NAME##_v = has_##NAME<ITERABLE>::value;
STROIKA_FOUNDATION_CONFIGURATION_DEFINE_HAS (eq, (x == x)); // SEE https://stroika.atlassian.net/browse/STK-749
STROIKA_FOUNDATION_CONFIGURATION_DEFINE_HAS (equal_to, (static_cast<bool> (std::equal_to<X>{}(x, x))));
template <typename T1, typename T2> \
struct has_eq<std::pair<T1, T2>> : integral_constant<bool, has_eq<T1>::value && has_eq<T1>::value> {};
class SimpleClassWithoutComparisonOperators
{
public:
SimpleClassWithoutComparisonOperators (size_t v);
SimpleClassWithoutComparisonOperators (const
SimpleClassWithoutComparisonOperators
& f);
~SimpleClassWithoutComparisonOperators ();
size_t GetValue () const;
static size_t GetTotalLiveCount ();
//explicit operator size_t () const { return fValue; }
SimpleClassWithoutComparisonOperators operator+ (const
SimpleClassWithoutComparisonOperators
& rhs) const
{
return SimpleClassWithoutComparisonOperators (fValue + rhs.fValue);
}
private:
size_t fValue;
int fConstructed;
static size_t sTotalLiveObjects;
};
static_assert (!has_eq < SimpleClassWithoutComparisonOperators >::value);
using PAIR_ =
std::pair < SimpleClassWithoutComparisonOperators,
SimpleClassWithoutComparisonOperators >;
static_assert (!has_eq < PAIR_ >::value);
static_assert (has_eq <std::pair<int, int> >::value);
}
int main()
{
cout << "Hello World";
return 0;
}