Fix Compile error because of -Werror=effc++ is on
Fix #1170 Also fixed C++03 problem for using nullptr.
This commit is contained in:
parent
672e7dd373
commit
82b5c42567
@ -74,7 +74,7 @@ public:
|
|||||||
bool HasMember(const char* name) const;
|
bool HasMember(const char* name) const;
|
||||||
JsonReader& EndObject();
|
JsonReader& EndObject();
|
||||||
|
|
||||||
JsonReader& StartArray(size_t* size = nullptr);
|
JsonReader& StartArray(size_t* size = 0);
|
||||||
JsonReader& EndArray();
|
JsonReader& EndArray();
|
||||||
|
|
||||||
JsonReader& operator&(bool& b);
|
JsonReader& operator&(bool& b);
|
||||||
|
@ -6,6 +6,11 @@
|
|||||||
// Test1: simple object
|
// Test1: simple object
|
||||||
|
|
||||||
struct Student {
|
struct Student {
|
||||||
|
Student() : name(), age(), height(), canSwim() {}
|
||||||
|
Student(const std::string name, unsigned age, double height, bool canSwim) :
|
||||||
|
name(name), age(age), height(height), canSwim(canSwim)
|
||||||
|
{}
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
unsigned age;
|
unsigned age;
|
||||||
double height;
|
double height;
|
||||||
@ -31,7 +36,7 @@ void test1() {
|
|||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
{
|
{
|
||||||
Student s = { "Lua", 9, 150.5, true };
|
Student s("Lua", 9, 150.5, true);
|
||||||
|
|
||||||
JsonWriter writer;
|
JsonWriter writer;
|
||||||
writer & s;
|
writer & s;
|
||||||
@ -54,6 +59,7 @@ void test1() {
|
|||||||
// You can map a JSON array to other data structures as well
|
// You can map a JSON array to other data structures as well
|
||||||
|
|
||||||
struct Group {
|
struct Group {
|
||||||
|
Group() : groupName(), students() {}
|
||||||
std::string groupName;
|
std::string groupName;
|
||||||
std::vector<Student> students;
|
std::vector<Student> students;
|
||||||
};
|
};
|
||||||
@ -124,7 +130,7 @@ public:
|
|||||||
virtual void Print(std::ostream& os) const = 0;
|
virtual void Print(std::ostream& os) const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Shape() {}
|
Shape() : x_(), y_() {}
|
||||||
Shape(double x, double y) : x_(x), y_(y) {}
|
Shape(double x, double y) : x_(x), y_(y) {}
|
||||||
|
|
||||||
template <typename Archiver>
|
template <typename Archiver>
|
||||||
@ -142,7 +148,7 @@ Archiver& operator&(Archiver& ar, Shape& s) {
|
|||||||
|
|
||||||
class Circle : public Shape {
|
class Circle : public Shape {
|
||||||
public:
|
public:
|
||||||
Circle() {}
|
Circle() : radius_() {}
|
||||||
Circle(double x, double y, double radius) : Shape(x, y), radius_(radius) {}
|
Circle(double x, double y, double radius) : Shape(x, y), radius_(radius) {}
|
||||||
~Circle() {}
|
~Circle() {}
|
||||||
|
|
||||||
@ -168,7 +174,7 @@ Archiver& operator&(Archiver& ar, Circle& c) {
|
|||||||
|
|
||||||
class Box : public Shape {
|
class Box : public Shape {
|
||||||
public:
|
public:
|
||||||
Box() {}
|
Box() : width_(), height_() {}
|
||||||
Box(double x, double y, double width, double height) : Shape(x, y), width_(width), height_(height) {}
|
Box(double x, double y, double width, double height) : Shape(x, y), width_(width), height_(height) {}
|
||||||
~Box() {}
|
~Box() {}
|
||||||
|
|
||||||
@ -195,7 +201,7 @@ Archiver& operator&(Archiver& ar, Box& b) {
|
|||||||
|
|
||||||
class Canvas {
|
class Canvas {
|
||||||
public:
|
public:
|
||||||
Canvas() {}
|
Canvas() : shapes_() {}
|
||||||
~Canvas() { Clear(); }
|
~Canvas() { Clear(); }
|
||||||
|
|
||||||
void Clear() {
|
void Clear() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user