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
58397957
Commit
58397957
authored
Jan 08, 2017
by
Théo DELRIEU
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove useless helpers
parent
b4cea682
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
50 deletions
+6
-50
src/json.hpp
src/json.hpp
+3
-25
src/json.hpp.re2c
src/json.hpp.re2c
+3
-25
No files found.
src/json.hpp
View file @
58397957
...
...
@@ -152,23 +152,9 @@ template <bool B, typename T = void>
using
enable_if_t
=
typename
std
::
enable_if
<
B
,
T
>::
type
;
template
<
typename
T
>
using
remove_cv_t
=
typename
std
::
remove_cv
<
T
>::
type
;
template
<
typename
T
>
using
remove_reference_t
=
typename
std
::
remove_reference
<
T
>::
type
;
template
<
typename
T
>
using
uncvref_t
=
remove_cv_t
<
remove_reference_t
<
T
>>
;
template
<
bool
If
,
typename
Then
,
typename
Else
>
using
conditional_t
=
typename
std
::
conditional
<
If
,
Then
,
Else
>::
type
;
using
uncvref_t
=
typename
std
::
remove_cv
<
typename
std
::
remove_reference
<
T
>::
type
>::
type
;
// Taken from http://stackoverflow.com/questions/26936640/how-to-implement-is-enum-class-type-trait
template
<
typename
T
>
using
is_scoped_enum
=
std
::
integral_constant
<
bool
,
not
std
::
is_convertible
<
T
,
int
>::
value
and
std
::
is_enum
<
T
>::
value
>
;
template
<
typename
T
>
using
is_unscoped_enum
=
std
::
integral_constant
<
bool
,
std
::
is_convertible
<
T
,
int
>::
value
and
...
...
@@ -341,7 +327,7 @@ template <class...> struct conjunction : std::true_type {};
template
<
class
B1
>
struct
conjunction
<
B1
>
:
B1
{};
template
<
class
B1
,
class
...
Bn
>
struct
conjunction
<
B1
,
Bn
...
>
:
conditional_t
<
bool
(
B1
::
value
),
conjunction
<
Bn
...
>
,
B1
>
{};
:
std
::
conditional
<
bool
(
B1
::
value
),
conjunction
<
Bn
...
>
,
B1
>::
type
{};
template
<
class
B
>
struct
negation
:
std
::
integral_constant
<
bool
,
!
B
::
value
>
{};
...
...
@@ -389,8 +375,6 @@ struct is_compatible_object_type_impl<true, RealType, CompatibleObjectType>
template
<
class
BasicJson
,
class
CompatibleObjectType
>
struct
is_compatible_object_type
{
// As noted ahead, we need to stop evaluating traits if
// `CompatibleObjectType = void`, hence the conjunction
static
auto
constexpr
value
=
is_compatible_object_type_impl
<
conjunction
<
negation
<
std
::
is_same
<
void
,
CompatibleObjectType
>>
,
has_mapped_type
<
CompatibleObjectType
>
,
...
...
@@ -499,11 +483,6 @@ struct has_to_json
detect
(
std
::
declval
<
JSONSerializer
<
T
,
void
>>
()))
>::
value
;
};
// those declarations are needed to workaround a MSVC bug related to ADL
// (taken from MSVC-Ranges implementation)
void
to_json
();
void
from_json
();
// overloads for basic_json template parameters
template
<
typename
Json
,
typename
ArithmeticType
,
...
...
@@ -568,7 +547,7 @@ void to_json(Json &j, CompatibleNumberIntegerType val) noexcept
template
<
typename
Json
,
typename
UnscopedEnumType
,
enable_if_t
<
is_unscoped_enum
<
UnscopedEnumType
>
::
value
,
int
>
=
0
>
void
to_json
(
Json
&
j
,
UnscopedEnumType
e
)
void
to_json
(
Json
&
j
,
UnscopedEnumType
e
)
noexcept
{
external_constructor
<
value_t
::
number_integer
>::
construct
(
j
,
e
);
}
...
...
@@ -736,7 +715,6 @@ void from_json(Json const &j, ArithmeticType &val)
struct
to_json_fn
{
// is it really useful to mark those as constexpr?
template
<
typename
Json
,
typename
T
>
constexpr
auto
operator
()(
Json
&&
j
,
T
&&
val
)
const
noexcept
(
noexcept
(
to_json
(
std
::
forward
<
Json
>
(
j
),
std
::
forward
<
T
>
(
val
))))
...
...
src/json.hpp.re2c
View file @
58397957
...
...
@@ -152,23 +152,9 @@ template <bool B, typename T = void>
using enable_if_t = typename std::enable_if<B, T>::type;
template <typename T>
using remove_cv_t = typename std::remove_cv<T>::type;
template <typename T>
using remove_reference_t = typename std::remove_reference<T>::type;
template <typename T>
using uncvref_t = remove_cv_t<remove_reference_t<T>>;
template <bool If, typename Then, typename Else>
using conditional_t = typename std::conditional<If, Then, Else>::type;
using uncvref_t = typename std::remove_cv<typename std::remove_reference<T>::type>::type;
// Taken from http://stackoverflow.com/questions/26936640/how-to-implement-is-enum-class-type-trait
template <typename T>
using is_scoped_enum =
std::integral_constant<bool, not std::is_convertible<T, int>::value and
std::is_enum<T>::value>;
template <typename T>
using is_unscoped_enum =
std::integral_constant<bool, std::is_convertible<T, int>::value and
...
...
@@ -341,7 +327,7 @@ template <class...> struct conjunction : std::true_type {};
template <class B1> struct conjunction<B1> : B1 {};
template <class B1, class... Bn>
struct conjunction<B1, Bn...>
:
conditional_t<bool(B1::value), conjunction<Bn...>, B1>
{};
:
std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type
{};
template <class B> struct negation : std::integral_constant < bool, !B::value > {};
...
...
@@ -389,8 +375,6 @@ struct is_compatible_object_type_impl<true, RealType, CompatibleObjectType>
template<class BasicJson, class CompatibleObjectType>
struct is_compatible_object_type
{
// As noted ahead, we need to stop evaluating traits if
// `CompatibleObjectType = void`, hence the conjunction
static auto constexpr value = is_compatible_object_type_impl<
conjunction<negation<std::is_same<void, CompatibleObjectType>>,
has_mapped_type<CompatibleObjectType>,
...
...
@@ -499,11 +483,6 @@ struct has_to_json
detect(std::declval<JSONSerializer<T, void>>()))>::value;
};
// those declarations are needed to workaround a MSVC bug related to ADL
// (taken from MSVC-Ranges implementation)
void to_json();
void from_json();
// overloads for basic_json template parameters
template <typename Json, typename ArithmeticType,
...
...
@@ -568,7 +547,7 @@ void to_json(Json &j, CompatibleNumberIntegerType val) noexcept
template <typename Json, typename UnscopedEnumType,
enable_if_t<is_unscoped_enum<UnscopedEnumType>::value, int> = 0>
void to_json(Json &j, UnscopedEnumType e)
void to_json(Json &j, UnscopedEnumType e)
noexcept
{
external_constructor<value_t::number_integer>::construct(j, e);
}
...
...
@@ -736,7 +715,6 @@ void from_json(Json const &j, ArithmeticType &val)
struct to_json_fn
{
// is it really useful to mark those as constexpr?
template <typename Json, typename T>
constexpr auto operator()(Json&& j, T&& val) const
noexcept(noexcept(to_json(std::forward<Json>(j), std::forward<T>(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