Skip to content

In basic_json::basic_json(const CompatibleArrayType& val), the requirement of CompatibleArrayType is not strict enough. #174

Description

@jasper412

This is a question Ralated to #167 :
In basic_json::basic_json(const CompatibleArrayType& val), the requirement of CompatibleArrayType is not strict enough.

template <class CompatibleArrayType, typename
              std::enable_if<
                  not std::is_same<CompatibleArrayType, typename basic_json_t::iterator>::value and
                  not std::is_same<CompatibleArrayType, typename basic_json_t::const_iterator>::value and
                  not std::is_same<CompatibleArrayType, typename basic_json_t::reverse_iterator>::value and
                  not std::is_same<CompatibleArrayType, typename basic_json_t::const_reverse_iterator>::value and
                  not std::is_same<CompatibleArrayType, typename array_t::iterator>::value and
                  not std::is_same<CompatibleArrayType, typename array_t::const_iterator>::value and
                  std::is_constructible<basic_json, typename CompatibleArrayType::value_type>::value, int>::type
              = 0>
    basic_json(const CompatibleArrayType& val)
        : m_type(value_t::array)
    {
        using std::begin;
        using std::end;
        m_value.array = create<array_t>(begin(val), end(val));
    }

Template constructor of basic_json_t above can receive any type that has a type member value_type which can be used as the only parameter in one of basic_json_t's constructors and regard that type as a CompatibleArrayType.
I think the scope of the target types is too much wide, though it excludes some of the types already meet the requirement but are not CompatibleArrayType, still not fine with 3rd party types.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions