danielaparker / jsoncons

A C++, header-only library for constructing JSON and JSON-like data formats, with JSON Pointer, JSON Patch, JSON Schema, JSONPath, JMESPath, CSV, MessagePack, CBOR, BSON, UBJSON
https://danielaparker.github.io/jsoncons
Other
699 stars 158 forks source link

Why is jsonschema make_schema taking a const reference? #439

Closed Dantsz closed 1 year ago

Dantsz commented 1 year ago

Describe the proposed feature I can't get make_schema to work with std::function. https://godbolt.org/z/EnPe43jxK

What other libraries (C++ or other) have this feature?

Include a code fragment with sample data that illustrates the use of this feature Something like this, using an universal reference, allows moving from an std::function: https://godbolt.org/z/zPn35PefW

template <class Json,class URIResolver>
    typename std::enable_if<extension_traits::is_unary_function_object_exact<URIResolver,Json,std::string>::value,std::shared_ptr<json_schema<Json>>>::type
    make_schema(const Json& schema,URIResolver&& resolver)
    {
        keyword_factory<Json> kwFactory(std::forward<URIResolver>(resolver));
        kwFactory.load_root(schema);

        return kwFactory.get_schema();
    }