Skip to content

Commit

Permalink
make has_mapped_type struct friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
vpetrigo committed Oct 8, 2016
1 parent a0ef5a1 commit e9fde3e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,13 @@ template<typename T>
struct has_mapped_type
{
private:
template<typename C> static char test(typename C::mapped_type*);
template<typename C> static char (&test(...))[2];
template <typename U, typename = typename U::mapped_type>
static int detect(U&&);

static void detect(...);
public:
static constexpr bool value = sizeof(test<T>(0)) == 1;
static constexpr bool value =
std::is_integral<decltype(detect(std::declval<T>()))>::value;
};

/*!
Expand Down
9 changes: 6 additions & 3 deletions src/json.hpp.re2c
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,13 @@ template<typename T>
struct has_mapped_type
{
private:
template<typename C> static char test(typename C::mapped_type*);
template<typename C> static char (&test(...))[2];
template <typename U, typename = typename U::mapped_type>
static int detect(U&&);

static void detect(...);
public:
static constexpr bool value = sizeof(test<T>(0)) == 1;
static constexpr bool value =
std::is_integral<decltype(detect(std::declval<T>()))>::value;
};

/*!
Expand Down

0 comments on commit e9fde3e

Please sign in to comment.