Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I used rapidjson in my MFC VC++ project to parse and create some json strings.
But I have an error in document.h file :
new (this) GenericValue(i);


error is:
document.h(1739): error C2059: syntax error: 'this'


I don't know how resolve this problem.
please help me.

What I have tried:

document.h(1739): error C2059: syntax error: 'this'

rapidjson helping
Posted
Updated 15-Dec-17 2:19am

1 solution

Full code line in header:
C++
GenericValue& SetInt(int i) { this->~GenericValue(); new (this) GenericValue(i); return *this; }
The technique is called "placement new".

It seems to be a Visual Studio problem:
If DEBUG_NEW is defined in stdafx.h then code that uses placement new will not compile.

So try undefining that before including the header file or make a release build.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900