Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
json
Commits
b4cea682
Commit
b4cea682
authored
Jan 08, 2017
by
Théo DELRIEU
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove is_compatible_array_type_impl trait
parent
b2543e06
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
132 additions
and
84 deletions
+132
-84
src/json.hpp
src/json.hpp
+17
-42
src/json.hpp.re2c
src/json.hpp.re2c
+17
-42
src/json.hpp.re2c.rej
src/json.hpp.re2c.rej
+98
-0
No files found.
src/json.hpp
View file @
b4cea682
...
@@ -398,40 +398,30 @@ struct is_compatible_object_type
...
@@ -398,40 +398,30 @@ struct is_compatible_object_type
typename
BasicJson
::
object_t
,
CompatibleObjectType
>::
value
;
typename
BasicJson
::
object_t
,
CompatibleObjectType
>::
value
;
};
};
template
<
bool
B
,
class
BasicJson
,
class
CompatibleArrayType
>
template
<
typename
BasicJson
,
typename
T
>
struct
is_compatible_array_type_impl
:
std
::
false_type
{};
struct
is_basic_json_nested_type
template
<
class
BasicJson
,
class
CompatibleArrayType
>
struct
is_compatible_array_type_impl
<
true
,
BasicJson
,
CompatibleArrayType
>
{
{
static
constexpr
auto
value
=
static
auto
constexpr
value
=
std
::
is_same
<
T
,
typename
BasicJson
::
iterator
>::
value
or
not
std
::
is_same
<
CompatibleArrayType
,
std
::
is_same
<
T
,
typename
BasicJson
::
const_iterator
>::
value
or
typename
BasicJson
::
iterator
>::
value
and
std
::
is_same
<
T
,
typename
BasicJson
::
reverse_iterator
>::
value
or
not
std
::
is_same
<
CompatibleArrayType
,
std
::
is_same
<
T
,
typename
BasicJson
::
const_reverse_iterator
>::
value
or
typename
BasicJson
::
const_iterator
>::
value
and
std
::
is_same
<
T
,
typename
BasicJson
::
json_pointer
>::
value
;
not
std
::
is_same
<
CompatibleArrayType
,
typename
BasicJson
::
reverse_iterator
>::
value
and
not
std
::
is_same
<
CompatibleArrayType
,
typename
BasicJson
::
const_reverse_iterator
>::
value
and
not
std
::
is_same
<
CompatibleArrayType
,
typename
BasicJson
::
array_t
::
iterator
>::
value
and
not
std
::
is_same
<
CompatibleArrayType
,
typename
BasicJson
::
array_t
::
const_iterator
>::
value
;
};
};
template
<
class
BasicJson
,
class
CompatibleArrayType
>
template
<
class
BasicJson
,
class
CompatibleArrayType
>
struct
is_compatible_array_type
struct
is_compatible_array_type
{
{
// the check for CompatibleArrayType = void is done in
// TODO concept Container?
// `is_compatible_object_type`, but we need the conjunction here as well
// this might not make VS happy
static
auto
constexpr
value
=
is_compatible_array_type_impl
<
static
auto
constexpr
value
=
conjunction
<
negation
<
is_compatible_object_type
<
conjunction
<
negation
<
std
::
is_same
<
void
,
CompatibleArrayType
>>
,
negation
<
is_compatible_object_type
<
BasicJson
,
CompatibleArrayType
>>
,
BasicJson
,
CompatibleArrayType
>>
,
negation
<
std
::
is_constructible
<
typename
BasicJson
::
string_t
,
negation
<
std
::
is_constructible
<
typename
BasicJson
::
string_t
,
CompatibleArrayType
>>
,
CompatibleArrayType
>>
,
negation
<
is_basic_json_nested_type
<
BasicJson
,
CompatibleArrayType
>>
,
has_value_type
<
CompatibleArrayType
>
,
has_value_type
<
CompatibleArrayType
>
,
has_iterator
<
CompatibleArrayType
>>::
value
,
has_iterator
<
CompatibleArrayType
>>::
value
;
BasicJson
,
CompatibleArrayType
>::
value
;
};
};
template
<
bool
,
typename
,
typename
>
template
<
bool
,
typename
,
typename
>
...
@@ -461,16 +451,6 @@ struct is_compatible_integer_type
...
@@ -461,16 +451,6 @@ struct is_compatible_integer_type
RealIntegerType
,
CompatibleNumberIntegerType
>
::
value
;
RealIntegerType
,
CompatibleNumberIntegerType
>
::
value
;
};
};
template
<
typename
BasicJson
,
typename
T
>
struct
is_basic_json_nested_type
{
static
auto
constexpr
value
=
std
::
is_same
<
T
,
typename
BasicJson
::
iterator
>::
value
or
std
::
is_same
<
T
,
typename
BasicJson
::
const_iterator
>::
value
or
std
::
is_same
<
T
,
typename
BasicJson
::
reverse_iterator
>::
value
or
std
::
is_same
<
T
,
typename
BasicJson
::
const_reverse_iterator
>::
value
or
std
::
is_same
<
T
,
typename
BasicJson
::
json_pointer
>::
value
;
};
// This trait checks if JSONSerializer<T>::from_json(json const&, udt&) exists
// This trait checks if JSONSerializer<T>::from_json(json const&, udt&) exists
template
<
template
<
typename
,
typename
>
class
JSONSerializer
,
typename
Json
,
typename
T
>
template
<
template
<
typename
,
typename
>
class
JSONSerializer
,
typename
Json
,
typename
T
>
struct
has_from_json
struct
has_from_json
...
@@ -519,8 +499,6 @@ struct has_to_json
...
@@ -519,8 +499,6 @@ struct has_to_json
detect
(
std
::
declval
<
JSONSerializer
<
T
,
void
>>
()))
>::
value
;
detect
(
std
::
declval
<
JSONSerializer
<
T
,
void
>>
()))
>::
value
;
};
};
template
<
typename
Json
,
typename
>
// those declarations are needed to workaround a MSVC bug related to ADL
// those declarations are needed to workaround a MSVC bug related to ADL
// (taken from MSVC-Ranges implementation)
// (taken from MSVC-Ranges implementation)
void
to_json
();
void
to_json
();
...
@@ -737,12 +715,9 @@ template <
...
@@ -737,12 +715,9 @@ template <
typename
Json
,
typename
ArithmeticType
,
typename
Json
,
typename
ArithmeticType
,
enable_if_t
<
enable_if_t
<
std
::
is_arithmetic
<
ArithmeticType
>
::
value
and
std
::
is_arithmetic
<
ArithmeticType
>
::
value
and
not
std
::
is_same
<
ArithmeticType
,
not
std
::
is_same
<
ArithmeticType
,
typename
Json
::
number_unsigned_t
>::
value
and
typename
Json
::
number_unsigned_t
>::
value
and
not
std
::
is_same
<
ArithmeticType
,
typename
Json
::
number_integer_t
>::
value
and
not
std
::
is_same
<
ArithmeticType
,
not
std
::
is_same
<
ArithmeticType
,
typename
Json
::
number_float_t
>::
value
and
typename
Json
::
number_integer_t
>::
value
and
not
std
::
is_same
<
ArithmeticType
,
typename
Json
::
number_float_t
>::
value
and
not
std
::
is_same
<
ArithmeticType
,
typename
Json
::
boolean_t
>::
value
,
not
std
::
is_same
<
ArithmeticType
,
typename
Json
::
boolean_t
>::
value
,
int
>
=
0
>
int
>
=
0
>
void
from_json
(
Json
const
&
j
,
ArithmeticType
&
val
)
void
from_json
(
Json
const
&
j
,
ArithmeticType
&
val
)
...
...
src/json.hpp.re2c
View file @
b4cea682
...
@@ -398,40 +398,30 @@ struct is_compatible_object_type
...
@@ -398,40 +398,30 @@ struct is_compatible_object_type
typename BasicJson::object_t, CompatibleObjectType>::value;
typename BasicJson::object_t, CompatibleObjectType>::value;
};
};
template <bool B, class BasicJson, class CompatibleArrayType>
template <typename BasicJson, typename T>
struct is_compatible_array_type_impl : std::false_type {};
struct is_basic_json_nested_type
template <class BasicJson, class CompatibleArrayType>
struct is_compatible_array_type_impl<true, BasicJson, CompatibleArrayType>
{
{
static constexpr auto value =
static auto constexpr value = std::is_same<T, typename BasicJson::iterator>::value or
not std::is_same<CompatibleArrayType,
std::is_same<T, typename BasicJson::const_iterator>::value or
typename BasicJson::iterator>::value and
std::is_same<T, typename BasicJson::reverse_iterator>::value or
not std::is_same<CompatibleArrayType,
std::is_same<T, typename BasicJson::const_reverse_iterator>::value or
typename BasicJson::const_iterator>::value and
std::is_same<T, typename BasicJson::json_pointer>::value;
not std::is_same<CompatibleArrayType,
typename BasicJson::reverse_iterator>::value and
not std::is_same<CompatibleArrayType,
typename BasicJson::const_reverse_iterator>::value and
not std::is_same<CompatibleArrayType,
typename BasicJson::array_t::iterator>::value and
not std::is_same<CompatibleArrayType,
typename BasicJson::array_t::const_iterator>::value;
};
};
template <class BasicJson, class CompatibleArrayType>
template <class BasicJson, class CompatibleArrayType>
struct is_compatible_array_type
struct is_compatible_array_type
{
{
// the check for CompatibleArrayType = void is done in
// TODO concept Container?
// `is_compatible_object_type`, but we need the conjunction here as well
// this might not make VS happy
static auto constexpr value = is_compatible_array_type_impl<
static auto constexpr value =
conjunction<negation<is_compatible_object_type<
conjunction<negation<std::is_same<void, CompatibleArrayType>>,
negation<is_compatible_object_type<
BasicJson, CompatibleArrayType>>,
BasicJson, CompatibleArrayType>>,
negation<std::is_constructible<typename BasicJson::string_t,
negation<std::is_constructible<typename BasicJson::string_t,
CompatibleArrayType>>,
CompatibleArrayType>>,
negation<is_basic_json_nested_type<BasicJson, CompatibleArrayType>>,
has_value_type<CompatibleArrayType>,
has_value_type<CompatibleArrayType>,
has_iterator<CompatibleArrayType>>::value,
has_iterator<CompatibleArrayType>>::value;
BasicJson, CompatibleArrayType>::value;
};
};
template <bool, typename, typename>
template <bool, typename, typename>
...
@@ -461,16 +451,6 @@ struct is_compatible_integer_type
...
@@ -461,16 +451,6 @@ struct is_compatible_integer_type
RealIntegerType, CompatibleNumberIntegerType > ::value;
RealIntegerType, CompatibleNumberIntegerType > ::value;
};
};
template <typename BasicJson, typename T>
struct is_basic_json_nested_type
{
static auto constexpr value = std::is_same<T, typename BasicJson::iterator>::value or
std::is_same<T, typename BasicJson::const_iterator>::value or
std::is_same<T, typename BasicJson::reverse_iterator>::value or
std::is_same<T, typename BasicJson::const_reverse_iterator>::value or
std::is_same<T, typename BasicJson::json_pointer>::value;
};
// This trait checks if JSONSerializer<T>::from_json(json const&, udt&) exists
// This trait checks if JSONSerializer<T>::from_json(json const&, udt&) exists
template <template <typename, typename> class JSONSerializer, typename Json, typename T>
template <template <typename, typename> class JSONSerializer, typename Json, typename T>
struct has_from_json
struct has_from_json
...
@@ -519,8 +499,6 @@ struct has_to_json
...
@@ -519,8 +499,6 @@ struct has_to_json
detect(std::declval<JSONSerializer<T, void>>()))>::value;
detect(std::declval<JSONSerializer<T, void>>()))>::value;
};
};
template <typename Json, typename >
// those declarations are needed to workaround a MSVC bug related to ADL
// those declarations are needed to workaround a MSVC bug related to ADL
// (taken from MSVC-Ranges implementation)
// (taken from MSVC-Ranges implementation)
void to_json();
void to_json();
...
@@ -737,12 +715,9 @@ template <
...
@@ -737,12 +715,9 @@ template <
typename Json, typename ArithmeticType,
typename Json, typename ArithmeticType,
enable_if_t<
enable_if_t<
std::is_arithmetic<ArithmeticType>::value and
std::is_arithmetic<ArithmeticType>::value and
not std::is_same<ArithmeticType,
not std::is_same<ArithmeticType, typename Json::number_unsigned_t>::value and
typename Json::number_unsigned_t>::value and
not std::is_same<ArithmeticType, typename Json::number_integer_t>::value and
not std::is_same<ArithmeticType,
not std::is_same<ArithmeticType, typename Json::number_float_t>::value and
typename Json::number_integer_t>::value and
not std::is_same<ArithmeticType,
typename Json::number_float_t>::value and
not std::is_same<ArithmeticType, typename Json::boolean_t>::value,
not std::is_same<ArithmeticType, typename Json::boolean_t>::value,
int> = 0>
int> = 0>
void from_json(Json const &j, ArithmeticType &val)
void from_json(Json const &j, ArithmeticType &val)
...
...
src/json.hpp.re2c.rej
0 → 100644
View file @
b4cea682
diff a/src/json.hpp.re2c b/src/json.hpp.re2c (rejected hunks)
@@ -389,40 +389,30 @@
struct is_compatible_object_type
typename BasicJson::object_t, CompatibleObjectType>::value;
};
-template <bool B, class BasicJson, class CompatibleArrayType>
-struct is_compatible_array_type_impl : std::false_type {};
-
-template <class BasicJson, class CompatibleArrayType>
-struct is_compatible_array_type_impl<true, BasicJson, CompatibleArrayType>
+template <typename BasicJson, typename T>
+struct is_basic_json_nested_type
{
- static constexpr auto value =
- not std::is_same<CompatibleArrayType,
- typename BasicJson::iterator>::value and
- not std::is_same<CompatibleArrayType,
- typename BasicJson::const_iterator>::value and
- not std::is_same<CompatibleArrayType,
- typename BasicJson::reverse_iterator>::value and
- not std::is_same<CompatibleArrayType,
- typename BasicJson::const_reverse_iterator>::value and
- not std::is_same<CompatibleArrayType,
- typename BasicJson::array_t::iterator>::value and
- not std::is_same<CompatibleArrayType,
- typename BasicJson::array_t::const_iterator>::value;
+ static auto constexpr value = std::is_same<T, typename BasicJson::iterator>::value or
+ std::is_same<T, typename BasicJson::const_iterator>::value or
+ std::is_same<T, typename BasicJson::reverse_iterator>::value or
+ std::is_same<T, typename BasicJson::const_reverse_iterator>::value or
+ std::is_same<T, typename BasicJson::json_pointer>::value;
};
template <class BasicJson, class CompatibleArrayType>
struct is_compatible_array_type
{
- // the check for CompatibleArrayType = void is done in
- // `is_compatible_object_type`, but we need the conjunction here as well
- static auto constexpr value = is_compatible_array_type_impl<
- conjunction<negation<is_compatible_object_type<
+ // TODO concept Container?
+ // this might not make VS happy
+ static auto constexpr value =
+ conjunction<negation<std::is_same<void, CompatibleArrayType>>,
+ negation<is_compatible_object_type<
BasicJson, CompatibleArrayType>>,
negation<std::is_constructible<typename BasicJson::string_t,
CompatibleArrayType>>,
+ negation<is_basic_json_nested_type<BasicJson, CompatibleArrayType>>,
has_value_type<CompatibleArrayType>,
- has_iterator<CompatibleArrayType>>::value,
- BasicJson, CompatibleArrayType>::value;
+ has_iterator<CompatibleArrayType>>::value;
};
template <bool, typename, typename>
@@ -452,16 +442,6 @@
struct is_compatible_integer_type
RealIntegerType, CompatibleNumberIntegerType > ::value;
};
-template <typename BasicJson, typename T>
-struct is_basic_json_nested_type
-{
- static auto constexpr value = std::is_same<T, typename BasicJson::iterator>::value or
- std::is_same<T, typename BasicJson::const_iterator>::value or
- std::is_same<T, typename BasicJson::reverse_iterator>::value or
- std::is_same<T, typename BasicJson::const_reverse_iterator>::value or
- std::is_same<T, typename BasicJson::json_pointer>::value;
-};
-
// This trait checks if JSONSerializer<T>::from_json(json const&, udt&) exists
template <template <typename, typename> class JSONSerializer, typename Json, typename T>
struct has_from_json
@@ -510,8 +490,6 @@
struct has_to_json
detect(std::declval<JSONSerializer<T, void>>()))>::value;
};
-template <typename Json, typename >
-
// those declarations are needed to workaround a MSVC bug related to ADL
// (taken from MSVC-Ranges implementation)
void to_json();
@@ -728,12 +706,9 @@
template <
typename Json, typename ArithmeticType,
enable_if_t<
std::is_arithmetic<ArithmeticType>::value and
- not std::is_same<ArithmeticType,
- typename Json::number_unsigned_t>::value and
- not std::is_same<ArithmeticType,
- typename Json::number_integer_t>::value and
- not std::is_same<ArithmeticType,
- typename Json::number_float_t>::value and
+ not std::is_same<ArithmeticType, typename Json::number_unsigned_t>::value and
+ not std::is_same<ArithmeticType, typename Json::number_integer_t>::value and
+ not std::is_same<ArithmeticType, typename Json::number_float_t>::value and
not std::is_same<ArithmeticType, typename Json::boolean_t>::value,
int> = 0>
void from_json(Json const &j, ArithmeticType &val)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment