Skip to content

wrong enable_if for const pointer (instead of pointer-to-const) #134

@dariomt

Description

@dariomt

Hi ,
The following test fails to compile:

const json value = {{"one", 1}, {"two", 2}};
const json::object_t* p = value.get_ptr<const json::object_t*>();

But this compiles (note the extra const):

const json value = {{"one", 1}, {"two", 2}};
const json::object_t* const q = value.get_ptr<const json::object_t* const>();

I think that the problem is the additional check for the const overload of get_ptr
and std::is_const<PointerType>::value

I think what you intended was to check that the template parameter is a "pointer-to-const" but what you are actually checking is if you got a "const pointer".

I believe the right fix is to check for "pointer-to-const" like this:
and std::is_const< typename std::remove_pointer<PointerType>::type >::value
It works in VS2015.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions