Merge pull request #324 from vpetrigo/has_mapped_improve

make has_mapped_type struct friendly
This commit is contained in:
Niels Lohmann 2016-10-12 21:59:56 +02:00 committed by GitHub
commit bb9d87ad55
2 changed files with 12 additions and 6 deletions

View file

@ -113,10 +113,13 @@ template<typename T>
struct has_mapped_type struct has_mapped_type
{ {
private: private:
template<typename C> static char test(typename C::mapped_type*); template <typename U, typename = typename U::mapped_type>
template<typename C> static char (&test(...))[2]; static int detect(U&&);
static void detect(...);
public: public:
static constexpr bool value = sizeof(test<T>(0)) == 1; static constexpr bool value =
std::is_integral<decltype(detect(std::declval<T>()))>::value;
}; };
/*! /*!

View file

@ -113,10 +113,13 @@ template<typename T>
struct has_mapped_type struct has_mapped_type
{ {
private: private:
template<typename C> static char test(typename C::mapped_type*); template <typename U, typename = typename U::mapped_type>
template<typename C> static char (&test(...))[2]; static int detect(U&&);
static void detect(...);
public: public:
static constexpr bool value = sizeof(test<T>(0)) == 1; static constexpr bool value =
std::is_integral<decltype(detect(std::declval<T>()))>::value;
}; };
/*! /*!