Support GCC 4.7

Removed constructors inheritance.
Removed emplace use.

Change-Id: I45224e3232d39ff22f758c7e387be2c9aff5eae0
Reviewed-on: https://weave-review.googlesource.com/1606
Reviewed-by: Vitaly Buka <vitalybuka@google.com>
diff --git a/src/commands/command_dictionary.cc b/src/commands/command_dictionary.cc
index 8fb7f43..516961f 100644
--- a/src/commands/command_dictionary.cc
+++ b/src/commands/command_dictionary.cc
@@ -62,7 +62,8 @@
         return false;
       }
 
-      new_defs.emplace(full_command_name, std::move(command_def));
+      new_defs.insert(
+          std::make_pair(full_command_name, std::move(command_def)));
       command_iter.Advance();
     }
     package_iter.Advance();
@@ -81,7 +82,7 @@
 
   // Insert new definitions into the global map.
   for (auto& pair : new_defs)
-    definitions_.emplace(pair.first, std::move(pair.second));
+    definitions_.insert(std::make_pair(pair.first, std::move(pair.second)));
   return true;
 }
 
diff --git a/src/commands/command_dictionary_unittest.cc b/src/commands/command_dictionary_unittest.cc
index 5cecd76..7298363 100644
--- a/src/commands/command_dictionary_unittest.cc
+++ b/src/commands/command_dictionary_unittest.cc
@@ -36,7 +36,7 @@
   })");
   CommandDictionary dict;
   EXPECT_TRUE(dict.LoadCommands(*json, nullptr));
-  EXPECT_EQ(1, dict.GetSize());
+  EXPECT_EQ(1u, dict.GetSize());
   EXPECT_NE(nullptr, dict.FindCommand("robot.jump"));
   json = CreateDictionaryValue(R"({
     'base': {
@@ -48,7 +48,7 @@
     }
   })");
   EXPECT_TRUE(dict.LoadCommands(*json, nullptr));
-  EXPECT_EQ(3, dict.GetSize());
+  EXPECT_EQ(3u, dict.GetSize());
   EXPECT_NE(nullptr, dict.FindCommand("robot.jump"));
   EXPECT_NE(nullptr, dict.FindCommand("base.reboot"));
   EXPECT_NE(nullptr, dict.FindCommand("base.shutdown"));
diff --git a/src/commands/command_manager_unittest.cc b/src/commands/command_manager_unittest.cc
index eca5175..2b2b055 100644
--- a/src/commands/command_manager_unittest.cc
+++ b/src/commands/command_manager_unittest.cc
@@ -75,7 +75,7 @@
     }
   })";
   EXPECT_TRUE(manager.LoadCommands(json_str, nullptr));
-  EXPECT_EQ(2, manager.GetCommandDictionary().GetSize());
+  EXPECT_EQ(2u, manager.GetCommandDictionary().GetSize());
   EXPECT_NE(nullptr, manager.GetCommandDictionary().FindCommand("base.reboot"));
   EXPECT_NE(nullptr, manager.GetCommandDictionary().FindCommand("robot._jump"));
 }
@@ -84,7 +84,7 @@
   CommandManager manager;
   ASSERT_TRUE(manager.LoadCommands(kTestVendorCommands, nullptr));
   ASSERT_TRUE(manager.LoadCommands(kTestTestCommands, nullptr));
-  EXPECT_EQ(3, manager.GetCommandDictionary().GetSize());
+  EXPECT_EQ(3u, manager.GetCommandDictionary().GetSize());
   EXPECT_NE(nullptr, manager.GetCommandDictionary().FindCommand("robot._jump"));
   EXPECT_NE(nullptr,
             manager.GetCommandDictionary().FindCommand("robot._speak"));
diff --git a/src/commands/command_queue.cc b/src/commands/command_queue.cc
index e08527b..3d2167f 100644
--- a/src/commands/command_queue.cc
+++ b/src/commands/command_queue.cc
@@ -38,7 +38,8 @@
       }
     }
 
-    CHECK(command_callbacks_.emplace(command_name, callback).second)
+    CHECK(command_callbacks_.insert(std::make_pair(command_name, callback))
+              .second)
         << command_name << " already has handler";
 
   } else {
diff --git a/src/commands/command_queue_unittest.cc b/src/commands/command_queue_unittest.cc
index a9e953e..394ae20 100644
--- a/src/commands/command_queue_unittest.cc
+++ b/src/commands/command_queue_unittest.cc
@@ -84,14 +84,14 @@
 
 TEST_F(CommandQueueTest, Empty) {
   EXPECT_TRUE(queue_.IsEmpty());
-  EXPECT_EQ(0, queue_.GetCount());
+  EXPECT_EQ(0u, queue_.GetCount());
 }
 
 TEST_F(CommandQueueTest, Add) {
   queue_.Add(CreateDummyCommandInstance("base.reboot", "id1"));
   queue_.Add(CreateDummyCommandInstance("base.reboot", "id2"));
   queue_.Add(CreateDummyCommandInstance("base.reboot", "id3"));
-  EXPECT_EQ(3, queue_.GetCount());
+  EXPECT_EQ(3u, queue_.GetCount());
   EXPECT_FALSE(queue_.IsEmpty());
 }
 
@@ -102,31 +102,31 @@
   queue_.Add(CreateDummyCommandInstance("base.reboot", id2));
   EXPECT_FALSE(queue_.IsEmpty());
   EXPECT_FALSE(Remove("dummy"));
-  EXPECT_EQ(2, queue_.GetCount());
+  EXPECT_EQ(2u, queue_.GetCount());
   EXPECT_TRUE(Remove(id1));
-  EXPECT_EQ(1, queue_.GetCount());
+  EXPECT_EQ(1u, queue_.GetCount());
   EXPECT_FALSE(Remove(id1));
-  EXPECT_EQ(1, queue_.GetCount());
+  EXPECT_EQ(1u, queue_.GetCount());
   EXPECT_TRUE(Remove(id2));
-  EXPECT_EQ(0, queue_.GetCount());
+  EXPECT_EQ(0u, queue_.GetCount());
   EXPECT_FALSE(Remove(id2));
-  EXPECT_EQ(0, queue_.GetCount());
+  EXPECT_EQ(0u, queue_.GetCount());
   EXPECT_TRUE(queue_.IsEmpty());
 }
 
 TEST_F(CommandQueueTest, DelayedRemove) {
   const std::string id1 = "id1";
   queue_.Add(CreateDummyCommandInstance("base.reboot", id1));
-  EXPECT_EQ(1, queue_.GetCount());
+  EXPECT_EQ(1u, queue_.GetCount());
 
   queue_.DelayedRemove(id1);
-  EXPECT_EQ(1, queue_.GetCount());
+  EXPECT_EQ(1u, queue_.GetCount());
 
   Cleanup(base::TimeDelta::FromMinutes(1));
-  EXPECT_EQ(1, queue_.GetCount());
+  EXPECT_EQ(1u, queue_.GetCount());
 
   Cleanup(base::TimeDelta::FromMinutes(15));
-  EXPECT_EQ(0, queue_.GetCount());
+  EXPECT_EQ(0u, queue_.GetCount());
 }
 
 TEST_F(CommandQueueTest, Dispatch) {
diff --git a/src/commands/object_schema.cc b/src/commands/object_schema.cc
index b70beff..6cfa5f4 100644
--- a/src/commands/object_schema.cc
+++ b/src/commands/object_schema.cc
@@ -283,7 +283,8 @@
 std::unique_ptr<ObjectSchema> ObjectSchema::Clone() const {
   std::unique_ptr<ObjectSchema> cloned{new ObjectSchema};
   for (const auto& pair : properties_) {
-    cloned->properties_.emplace(pair.first, pair.second->Clone());
+    cloned->properties_.insert(
+        std::make_pair(pair.first, pair.second->Clone()));
   }
   cloned->extra_properties_allowed_ = extra_properties_allowed_;
   return cloned;
@@ -335,7 +336,7 @@
         object_schema ? object_schema->GetProp(iter.key()) : nullptr;
     auto prop_type = PropFromJson(iter.value(), base_schema, error);
     if (prop_type) {
-      properties.emplace(iter.key(), std::move(prop_type));
+      properties.insert(std::make_pair(iter.key(), std::move(prop_type)));
     } else {
       Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
                          errors::commands::kInvalidPropDef,
diff --git a/src/commands/object_schema_unittest.cc b/src/commands/object_schema_unittest.cc
index 6417952..7cdc16d 100644
--- a/src/commands/object_schema_unittest.cc
+++ b/src/commands/object_schema_unittest.cc
@@ -1664,7 +1664,7 @@
   value = prop.CreatePropValue(*CreateDictionaryValue(val_json).get(), nullptr);
   ASSERT_NE(nullptr, value);
   obj = value->GetObject()->GetValue();
-  EXPECT_EQ(3, obj.size());
+  EXPECT_EQ(3u, obj.size());
 
   EXPECT_EQ(100, obj["param1"]->GetInt()->GetValue());
   EXPECT_EQ(obj.end(), obj.find("param2"));
diff --git a/src/commands/prop_types.cc b/src/commands/prop_types.cc
index 88a53bd..def68b1 100644
--- a/src/commands/prop_types.cc
+++ b/src/commands/prop_types.cc
@@ -110,7 +110,8 @@
   auto cloned = PropType::Create(GetType());
   cloned->based_on_schema_ = based_on_schema_;
   for (const auto& pair : constraints_) {
-    cloned->constraints_.emplace(pair.first, pair.second->Clone());
+    cloned->constraints_.insert(
+        std::make_pair(pair.first, pair.second->Clone()));
   }
   cloned->default_.is_inherited = default_.is_inherited;
   if (default_.value)
@@ -143,7 +144,8 @@
     return false;
   if (base_schema) {
     for (const auto& pair : base_schema->GetConstraints()) {
-      constraints_.emplace(pair.first, pair.second->CloneAsInherited());
+      constraints_.insert(
+          std::make_pair(pair.first, pair.second->CloneAsInherited()));
     }
   }
   if (!ConstraintsFromJson(value, &processed_keys, error))
diff --git a/src/commands/prop_values.h b/src/commands/prop_values.h
index f0a401e..960802b 100644
--- a/src/commands/prop_values.h
+++ b/src/commands/prop_values.h
@@ -130,7 +130,7 @@
 template <typename T>
 class TypedValueBase : public PropValue {
  public:
-  using PropValue::PropValue;
+  TypedValueBase(const PropType& type) : PropValue(type) {}
 
   // Overrides from PropValue base class.
   ValueType GetType() const override { return GetValueType<T>(); }
@@ -164,11 +164,9 @@
 template <typename Derived, typename T>
 class TypedValueWithClone : public TypedValueBase<T> {
  public:
-  using Base = TypedValueWithClone<Derived, T>;
-
-  // Expose the custom constructor of the base class.
-  using TypedValueBase<T>::TypedValueBase;
-  using PropValue::GetPropType;
+  TypedValueWithClone(const PropType& type) : TypedValueBase<T>(type) {}
+  TypedValueWithClone(const PropType& type, const T& value)
+      : TypedValueBase<T>(type, value) {}
 
   std::unique_ptr<PropValue> Clone() const override {
     return std::unique_ptr<PropValue>{
@@ -183,7 +181,7 @@
       return nullptr;
 
     // Only place where invalid value can exist.
-    std::unique_ptr<Derived> result{new Derived{type, tmp_value}};
+    std::unique_ptr<Derived> result(new Derived(type, tmp_value));
     if (!result->GetPropType()->ValidateConstraints(*result, error))
       return nullptr;
 
@@ -194,8 +192,11 @@
 // Value of type Integer.
 class IntValue final : public TypedValueWithClone<IntValue, int> {
  public:
-  using Base::Base;
-  friend class TypedValueWithClone<IntValue, int>;
+  explicit IntValue(const PropType& type)
+      : TypedValueWithClone<IntValue, int>(type) {}
+  IntValue(const PropType& type, int value)
+      : TypedValueWithClone<IntValue, int>(type, value) {}
+
   IntValue* GetInt() override { return this; }
   IntValue const* GetInt() const override { return this; }
 };
@@ -203,8 +204,11 @@
 // Value of type Number.
 class DoubleValue final : public TypedValueWithClone<DoubleValue, double> {
  public:
-  using Base::Base;
-  friend class TypedValueWithClone<DoubleValue, double>;
+  explicit DoubleValue(const PropType& type)
+      : TypedValueWithClone<DoubleValue, double>(type) {}
+  DoubleValue(const PropType& type, double value)
+      : TypedValueWithClone<DoubleValue, double>(type, value) {}
+
   DoubleValue* GetDouble() override { return this; }
   DoubleValue const* GetDouble() const override { return this; }
 };
@@ -212,8 +216,11 @@
 // Value of type String.
 class StringValue final : public TypedValueWithClone<StringValue, std::string> {
  public:
-  using Base::Base;
-  friend class TypedValueWithClone<StringValue, std::string>;
+  explicit StringValue(const PropType& type)
+      : TypedValueWithClone<StringValue, std::string>(type) {}
+  StringValue(const PropType& type, std::string value)
+      : TypedValueWithClone<StringValue, std::string>(type, value) {}
+
   StringValue* GetString() override { return this; }
   StringValue const* GetString() const override { return this; }
 };
@@ -221,8 +228,11 @@
 // Value of type Boolean.
 class BooleanValue final : public TypedValueWithClone<BooleanValue, bool> {
  public:
-  using Base::Base;
-  friend class TypedValueWithClone<BooleanValue, bool>;
+  explicit BooleanValue(const PropType& type)
+      : TypedValueWithClone<BooleanValue, bool>(type) {}
+  BooleanValue(const PropType& type, bool value)
+      : TypedValueWithClone<BooleanValue, bool>(type, value) {}
+
   BooleanValue* GetBoolean() override { return this; }
   BooleanValue const* GetBoolean() const override { return this; }
 };
@@ -230,8 +240,11 @@
 // Value of type Object.
 class ObjectValue final : public TypedValueWithClone<ObjectValue, ValueMap> {
  public:
-  using Base::Base;
-  friend class TypedValueWithClone<ObjectValue, ValueMap>;
+  explicit ObjectValue(const PropType& type)
+      : TypedValueWithClone<ObjectValue, ValueMap>(type) {}
+  ObjectValue(const PropType& type, ValueMap value)
+      : TypedValueWithClone<ObjectValue, ValueMap>(type, value) {}
+
   ObjectValue* GetObject() override { return this; }
   ObjectValue const* GetObject() const override { return this; }
 };
@@ -239,8 +252,11 @@
 // Value of type Array.
 class ArrayValue final : public TypedValueWithClone<ArrayValue, ValueVector> {
  public:
-  using Base::Base;
-  friend class TypedValueWithClone<ArrayValue, ValueVector>;
+  explicit ArrayValue(const PropType& type)
+      : TypedValueWithClone<ArrayValue, ValueVector>(type) {}
+  ArrayValue(const PropType& type, ValueVector value)
+      : TypedValueWithClone<ArrayValue, ValueVector>(type, value) {}
+
   ArrayValue* GetArray() override { return this; }
   ArrayValue const* GetArray() const override { return this; }
 };
diff --git a/src/commands/schema_utils.cc b/src/commands/schema_utils.cc
index 3c3e949..be6cb16 100644
--- a/src/commands/schema_utils.cc
+++ b/src/commands/schema_utils.cc
@@ -155,10 +155,10 @@
                            pair.first.c_str());
         return false;
       }
-      value_out->emplace_hint(value_out->end(), pair.first, std::move(value));
+      value_out->insert(std::make_pair(pair.first, std::move(value)));
       keys_processed.insert(pair.first);
     } else if (def_value) {
-      value_out->emplace_hint(value_out->end(), pair.first, def_value->Clone());
+      value_out->insert(std::make_pair(pair.first, def_value->Clone()));
       keys_processed.insert(pair.first);
     } else if (pair.second->IsRequired()) {
       return ErrorMissingProperty(error, FROM_HERE, pair.first.c_str());