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

GCC 8.2.1. Compilation error: invalid conversion from... #1246

Closed
Ptomaine opened this issue Sep 18, 2018 · 3 comments
Closed

GCC 8.2.1. Compilation error: invalid conversion from... #1246

Ptomaine opened this issue Sep 18, 2018 · 3 comments

Comments

@Ptomaine
Copy link

  • What is the issue you have?
    The compilation error:
/include/nlohmann/detail/iterators/iter_impl.hpp:262:48: error: invalid conversion from 'const nlohmann::basic_json<ordered_map>*' to 'nlohma
nn::detail::iter_impl<nlohmann::basic_json<ordered_map> >::pointer' {aka 'nlohmann::basic_json<ordered_map>*'} [-fpermissive]
                 return &(m_it.object_iterator->second);
                         ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~

ordered_map is defined as following:

template<class Key, class T, class Ignore, class Allocator, class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
using ordered_map = tsl::ordered_map<Key, T, Hash, KeyEqual, typename std::allocator_traits<Allocator>::template rebind_alloc<std::pair<Key, T>>>;

namespace json
{
using namespace nlohmann;
using json_ord = basic_json<ordered_map>;
}

inline json::json_ord operator "" _json_ord(const char* s, std::size_t n)
{
    return json::json_ord::parse(s, s + n);
}

inline json::json_ord::json_pointer operator "" _json_ord_pointer(const char* s, std::size_t n)
{
    return json::json_ord::json_pointer(std::string(s, n));
}
  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?
    Just use the previous definitions to create a json object that uses ordered_map.

  • What is the expected behavior?
    No compilation errors or warnings.

  • And what is the actual behavior instead?
    A compilation error or warning if -fpermissive option provided.

  • Which compiler and operating system are you using? Is it a supported compiler?
    GCC/MinGW 8.2.1

  • Did you use a released version of the library or the version from the develop branch?
    The MinGW distribution package was downloaded from https://gcc-mcf.lhmouse.com/

  • If you experience a compilation error: can you compile and run the unit tests?

@nlohmann
Copy link
Owner

Related: #546

@nlohmann
Copy link
Owner

In #546, the following hint for integration was made: #546 (comment). I cannot compile your code snippet either - it seems that the interfaces of std::map and tsl::ordered_map and the library fails to compile because of this.

@nlohmann
Copy link
Owner

nlohmann commented Oct 5, 2018

I'm not sure what do do here...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants