-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
* clang refuses constexpr initializer_list, I think it might be correct * some template type deduction in auto deduced types is failing, I helped it along * Cannot get regular template user defined literal compiling, revert to gnu extension This still doesn't compile however: value_parser returns something dependent on array_parser array_parser returns something dependent on value_parser I'm not sure how gcc is able to compile this with auto return deduction, but clang really doesn't like it @elbeno
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -597,40 +597,43 @@ namespace JSON | |
return value_proxy{0, object_storage, string_storage}; | ||
} | ||
|
||
using Value_Proxy = value_proxy<NumObjects, cx::vector<value, NumObjects>, | ||
cx::basic_string<char, StringSize>>; | ||
|
||
template <typename K, | ||
std::enable_if_t<!std::is_integral<K>::value, int> = 0> | ||
constexpr auto operator[](const K& s) const { | ||
return value_proxy{0, object_storage, string_storage}[s]; | ||
return Value_Proxy{0, object_storage, string_storage}[s]; | ||
} | ||
template <typename K, | ||
std::enable_if_t<!std::is_integral<K>::value, int> = 0> | ||
constexpr auto operator[](const K& s) { | ||
return value_proxy{0, object_storage, string_storage}[s]; | ||
return Value_Proxy{0, object_storage, string_storage}[s]; | ||
} | ||
constexpr auto object_Size() const { | ||
return value_proxy{0, object_storage, string_storage}.object_Size(); | ||
return Value_Proxy{0, object_storage, string_storage}.object_Size(); | ||
} | ||
|
||
constexpr auto operator[](std::size_t idx) const { | ||
return value_proxy{0, object_storage, string_storage}[idx]; | ||
return Value_Proxy{0, object_storage, string_storage}[idx]; | ||
} | ||
constexpr auto operator[](std::size_t idx) { | ||
return value_proxy{0, object_storage, string_storage}[idx]; | ||
return Value_Proxy{0, object_storage, string_storage}[idx]; | ||
} | ||
constexpr auto array_Size() const { | ||
return value_proxy{0, object_storage, string_storage}.array_Size(); | ||
return Value_Proxy{0, object_storage, string_storage}.array_Size(); | ||
} | ||
|
||
constexpr auto is_Null() const { return object_storage[0].is_Null(); } | ||
|
||
constexpr decltype(auto) to_String() const { | ||
return value_proxy{0, object_storage, string_storage}.to_String(); | ||
return Value_Proxy{0, object_storage, string_storage}.to_String(); | ||
} | ||
constexpr decltype(auto) to_String() { | ||
return value_proxy{0, object_storage, string_storage}.to_String(); | ||
return Value_Proxy{0, object_storage, string_storage}.to_String(); | ||
} | ||
constexpr auto string_Size() const { | ||
return value_proxy{0, object_storage, string_storage}.string_Size(); | ||
return Value_Proxy{0, object_storage, string_storage}.string_Size(); | ||
} | ||
|
||
constexpr decltype(auto) to_Number() const { return object_storage[0].to_Number(); } | ||
|
@@ -650,16 +653,19 @@ namespace JSON | |
|
||
namespace literals | ||
{ | ||
|
||
// why cannot we get regular literal operator template here? | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
elbeno
Collaborator
|
||
template <typename T, T... Ts> | ||
constexpr auto operator "" _json() | ||
{ | ||
constexpr std::initializer_list<T> il{Ts...}; | ||
std::initializer_list<T> il{Ts...}; | ||
This comment has been minimized.
Sorry, something went wrong.
elbeno
Collaborator
|
||
// I tried using structured bindings here, but g++ says: | ||
// "error: decomposition declaration cannot be declared 'constexpr'" | ||
constexpr auto S = sizes<Ts...>(); | ||
return value_wrapper<S.num_objects, S.string_size>( | ||
std::string_view(il.begin(), il.size())); | ||
} | ||
|
||
} | ||
|
||
} |
1 comment
on commit 92b120c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re type deduction problems (mutual recursion of value_parser & array_parser): is this a problem with clang's template instantiation? All the foo_recur structs are templates and then inside any of the member functions, the entire class should be visible, right?
In an earlier incarnation I had the early unevaluated call to fail() to try to help the compiler deduce a lambda return type (
if (false) return fail(std::size_t{})(sv); |
Why indeed. I remember wondering that when writing this, of course I tried "regular" first...