]> sigrok.org Git - libsigrok.git/commitdiff
C++: Avoid std::map::emplace() for GCC 4.7 compatibility
authorDaniel Elstner <redacted>
Wed, 30 Dec 2015 17:39:48 +0000 (18:39 +0100)
committerUwe Hermann <redacted>
Sat, 2 Jan 2016 23:51:37 +0000 (00:51 +0100)
This fixes bug #720.

bindings/cxx/classes.cpp

index 3be1d99477d45818bd94598ff7a3b5391ff5599a..34edff8760c33a9575ad224a6763ea350c3a4a41 100644 (file)
@@ -128,19 +128,19 @@ Context::Context() :
        if (struct sr_dev_driver **driver_list = sr_driver_list(_structure))
                for (int i = 0; driver_list[i]; i++) {
                        unique_ptr<Driver> driver {new Driver{driver_list[i]}};
-                       _drivers.emplace(driver->name(), move(driver));
+                       _drivers.insert(make_pair(driver->name(), move(driver)));
                }
 
        if (const struct sr_input_module **input_list = sr_input_list())
                for (int i = 0; input_list[i]; i++) {
                        unique_ptr<InputFormat> input {new InputFormat{input_list[i]}};
-                       _input_formats.emplace(input->name(), move(input));
+                       _input_formats.insert(make_pair(input->name(), move(input)));
                }
 
        if (const struct sr_output_module **output_list = sr_output_list())
                for (int i = 0; output_list[i]; i++) {
                        unique_ptr<OutputFormat> output {new OutputFormat{output_list[i]}};
-                       _output_formats.emplace(output->name(), move(output));
+                       _output_formats.insert(make_pair(output->name(), move(output)));
                }
 }
 
@@ -161,7 +161,7 @@ map<string, shared_ptr<Driver>> Context::drivers()
        {
                const auto &name = entry.first;
                const auto &driver = entry.second;
-               result.emplace(name, driver->share_owned_by(shared_from_this()));
+               result.insert({name, driver->share_owned_by(shared_from_this())});
        }
        return result;
 }
@@ -173,7 +173,7 @@ map<string, shared_ptr<InputFormat>> Context::input_formats()
        {
                const auto &name = entry.first;
                const auto &input_format = entry.second;
-               result.emplace(name, input_format->share_owned_by(shared_from_this()));
+               result.insert({name, input_format->share_owned_by(shared_from_this())});
        }
        return result;
 }
@@ -185,7 +185,7 @@ map<string, shared_ptr<OutputFormat>> Context::output_formats()
        {
                const auto &name = entry.first;
                const auto &output_format = entry.second;
-               result.emplace(name, output_format->share_owned_by(shared_from_this()));
+               result.insert({name, output_format->share_owned_by(shared_from_this())});
        }
        return result;
 }
@@ -547,14 +547,14 @@ Device::Device(struct sr_dev_inst *structure) :
        {
                auto *const ch = static_cast<struct sr_channel *>(entry->data);
                unique_ptr<Channel> channel {new Channel{ch}};
-               _channels.emplace(ch, move(channel));
+               _channels.insert(make_pair(ch, move(channel)));
        }
 
        for (GSList *entry = sr_dev_inst_channel_groups_get(structure); entry; entry = entry->next)
        {
                auto *const cg = static_cast<struct sr_channel_group *>(entry->data);
                unique_ptr<ChannelGroup> group {new ChannelGroup{this, cg}};
-               _channel_groups.emplace(group->name(), move(group));
+               _channel_groups.insert(make_pair(group->name(), move(group)));
        }
 }
 
@@ -609,7 +609,7 @@ Device::channel_groups()
        {
                const auto &name = entry.first;
                const auto &channel_group = entry.second;
-               result.emplace(name, channel_group->share_owned_by(get_shared_from_this()));
+               result.insert({name, channel_group->share_owned_by(get_shared_from_this())});
        }
        return result;
 }
@@ -668,7 +668,7 @@ shared_ptr<Channel> UserDevice::add_channel(unsigned int index,
        GSList *const last = g_slist_last(sr_dev_inst_channels_get(Device::_structure));
        auto *const ch = static_cast<struct sr_channel *>(last->data);
        unique_ptr<Channel> channel {new Channel{ch}};
-       _channels.emplace(ch, move(channel));
+       _channels.insert(make_pair(ch, move(channel)));
        return get_channel(ch);
 }
 
@@ -891,7 +891,7 @@ Session::Session(shared_ptr<Context> context, string filename) :
        for (GSList *dev = dev_list; dev; dev = dev->next) {
                auto *const sdi = static_cast<struct sr_dev_inst *>(dev->data);
                unique_ptr<SessionDevice> device {new SessionDevice{sdi}};
-               _owned_devices.emplace(sdi, move(device));
+               _owned_devices.insert(make_pair(sdi, move(device)));
        }
        _context->_session = this;
 }
@@ -1255,7 +1255,7 @@ map<string, shared_ptr<Option>> InputFormat::options()
                        shared_ptr<Option> opt {
                                new Option{options[i], option_array},
                                default_delete<Option>{}};
-                       result.emplace(opt->id(), move(opt));
+                       result.insert({opt->id(), move(opt)});
                }
        }
        return result;
@@ -1404,7 +1404,7 @@ map<string, shared_ptr<Option>> OutputFormat::options()
                        shared_ptr<Option> opt {
                                new Option{options[i], option_array},
                                default_delete<Option>{}};
-                       result.emplace(opt->id(), move(opt));
+                       result.insert({opt->id(), move(opt)});
                }
        }
        return result;