From: Daniel Elstner Date: Wed, 30 Dec 2015 17:39:48 +0000 (+0100) Subject: C++: Avoid std::map::emplace() for GCC 4.7 compatibility X-Git-Tag: libsigrok-0.4.0~43 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=8c529898116e9a6bf7083fb3b748b24d006392a4;p=libsigrok.git C++: Avoid std::map::emplace() for GCC 4.7 compatibility This fixes bug #720. --- diff --git a/bindings/cxx/classes.cpp b/bindings/cxx/classes.cpp index 3be1d994..34edff87 100644 --- a/bindings/cxx/classes.cpp +++ b/bindings/cxx/classes.cpp @@ -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 {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 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 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> 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> 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> 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(entry->data); unique_ptr 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(entry->data); unique_ptr 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 UserDevice::add_channel(unsigned int index, GSList *const last = g_slist_last(sr_dev_inst_channels_get(Device::_structure)); auto *const ch = static_cast(last->data); unique_ptr 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, string filename) : for (GSList *dev = dev_list; dev; dev = dev->next) { auto *const sdi = static_cast(dev->data); unique_ptr 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> InputFormat::options() shared_ptr