Skip to content

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

@Ptomaine

Description

@Ptomaine
  • 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions