Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Custom data source" exemple make no sense #2423

Closed
2 tasks done
imwhocodes opened this issue Oct 6, 2020 · 2 comments
Closed
2 tasks done

"Custom data source" exemple make no sense #2423

imwhocodes opened this issue Oct 6, 2020 · 2 comments
Labels
kind: bug state: needs more info the author of the issue needs to provide more details

Comments

@imwhocodes
Copy link

imwhocodes commented Oct 6, 2020

"Custom data source" form readme exemple make no sense and does not compile (?)

  1. copy exemple
  2. paste
  3. compile

Some (I think are) problems:

  1. MyIterator begin(MyContainer& tgt) { return MyIterator{&tgt}; } does not compile, stop some complaining only if MyContainer& tgt is const (const MyContainer& tgt) but this make it useless

  2. reference operator*() const {return target.get_current(); } but target is a pointer (also null)

  3. MyIterator& operator++() {MyContainer.advance(); return *this; } what is supposed to be MyContainer.advance(); static? reference? pointer?

Tennsy 4 (Arduino)

Platformio on mac osx,
gcc-arm-embedded: 5.4.1
build_flags =
-std=c++17
-lstdc++
-lnosys
-fno-exceptions

  • latest release version 3.9.1 single header version
  • the develop branch single header version

ERROR LIST:

src/main.cpp:243:27:   required from here
lib/json.hpp:23225:37: error: no matching function for call to 'input_adapter(MyContainer&)'
         parser(detail::input_adapter(std::forward<InputType>(i)), cb, allow_exceptions, ignore_comments).parse(true, result);
src/main.cpp:243:27:   required from here
lib/json.hpp:5164:83: error: binding 'const MyContainer' to reference of type 'MyContainer&' discards qualifiers
 auto input_adapter(const ContainerType& container) -> decltype(input_adapter(begin(container), end(container)))
lib/json.hpp:5299:32: note:   template argument deduction/substitution failed:
lib/json.hpp:5198:30: error: no type named 'type' in 'struct std::enable_if<false, int>'
                int >::type = 0 >
src/main.cpp: In member function 'MyIterator& MyIterator::operator++()':
src/main.cpp:218:20: error: expected unqualified-id before '.' token
         MyContainer.advance();
src/main.cpp: In member function 'const char& MyIterator::operator*() const':
src/main.cpp:227:23: error: request for member 'get_current' in '((const MyIterator*)this)->MyIterator::target', which is of pointer type 'MyContainer* const' (maybe you meant to use '->' ?)
         return target.get_current();

Thanks in advance,
Luca

@nlohmann
Copy link
Owner

  • Can you compile the test suite?
  • Can you share more code, like src/main.cpp?

@nlohmann nlohmann added the state: needs more info the author of the issue needs to provide more details label Oct 14, 2020
@typevishal
Copy link

O bhai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug state: needs more info the author of the issue needs to provide more details
Projects
None yet
Development

No branches or pull requests

3 participants