Skip to content

Commit 82b5c42

Browse files
committed
Fix Compile error because of -Werror=effc++ is on
Fix Tencent#1170 Also fixed C++03 problem for using nullptr.
1 parent 672e7dd commit 82b5c42

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

example/archiver/archiver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class JsonReader {
7474
bool HasMember(const char* name) const;
7575
JsonReader& EndObject();
7676

77-
JsonReader& StartArray(size_t* size = nullptr);
77+
JsonReader& StartArray(size_t* size = 0);
7878
JsonReader& EndArray();
7979

8080
JsonReader& operator&(bool& b);

example/archiver/archivertest.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
// Test1: simple object
77

88
struct Student {
9+
Student() : name(), age(), height(), canSwim() {}
10+
Student(const std::string name, unsigned age, double height, bool canSwim) :
11+
name(name), age(age), height(height), canSwim(canSwim)
12+
{}
13+
914
std::string name;
1015
unsigned age;
1116
double height;
@@ -31,7 +36,7 @@ void test1() {
3136

3237
// Serialize
3338
{
34-
Student s = { "Lua", 9, 150.5, true };
39+
Student s("Lua", 9, 150.5, true);
3540

3641
JsonWriter writer;
3742
writer & s;
@@ -54,6 +59,7 @@ void test1() {
5459
// You can map a JSON array to other data structures as well
5560

5661
struct Group {
62+
Group() : groupName(), students() {}
5763
std::string groupName;
5864
std::vector<Student> students;
5965
};
@@ -124,7 +130,7 @@ class Shape {
124130
virtual void Print(std::ostream& os) const = 0;
125131

126132
protected:
127-
Shape() {}
133+
Shape() : x_(), y_() {}
128134
Shape(double x, double y) : x_(x), y_(y) {}
129135

130136
template <typename Archiver>
@@ -142,7 +148,7 @@ Archiver& operator&(Archiver& ar, Shape& s) {
142148

143149
class Circle : public Shape {
144150
public:
145-
Circle() {}
151+
Circle() : radius_() {}
146152
Circle(double x, double y, double radius) : Shape(x, y), radius_(radius) {}
147153
~Circle() {}
148154

@@ -168,7 +174,7 @@ Archiver& operator&(Archiver& ar, Circle& c) {
168174

169175
class Box : public Shape {
170176
public:
171-
Box() {}
177+
Box() : width_(), height_() {}
172178
Box(double x, double y, double width, double height) : Shape(x, y), width_(width), height_(height) {}
173179
~Box() {}
174180

@@ -195,7 +201,7 @@ Archiver& operator&(Archiver& ar, Box& b) {
195201

196202
class Canvas {
197203
public:
198-
Canvas() {}
204+
Canvas() : shapes_() {}
199205
~Canvas() { Clear(); }
200206

201207
void Clear() {

0 commit comments

Comments
 (0)