Added AGGREGATE_EMPLACE compat macro

This commit is contained in:
Charles Dang 2024-08-15 21:27:10 -04:00
parent 5170615e03
commit d33b4554ef
3 changed files with 12 additions and 12 deletions

View file

@ -28,6 +28,7 @@
#include "filesystem.hpp"
#include "font/sdl_ttf_compat.hpp"
#include "font/text.hpp"
#include "global.hpp"
#include "preferences/preferences.hpp"
#include "halo.hpp"
#include "hotkey/command_executor.hpp"
@ -1293,11 +1294,7 @@ void display::drawing_buffer_add(const drawing_layer layer, const map_location&
int(zoom_)
};
#ifdef __cpp_aggregate_paren_init
drawing_buffer_.emplace_back(generate_hex_key(layer, loc), draw_func, dest);
#else
drawing_buffer_.push_back({generate_hex_key(layer, loc), draw_func, dest});
#endif
drawing_buffer_.AGGREGATE_EMPLACE(generate_hex_key(layer, loc), draw_func, dest);
}
void display::drawing_buffer_commit()

View file

@ -77,3 +77,9 @@
#ifndef UNLIKELY
#define UNLIKELY
#endif
#ifdef __cpp_aggregate_paren_init
#define AGGREGATE_EMPLACE(...) emplace_back(__VA_ARGS__)
#else
#define AGGREGATE_EMPLACE(...) push_back({ __VA_ARGS__ })
#endif

View file

@ -20,13 +20,14 @@
#include "terrain/builder.hpp"
#include "game_config_view.hpp"
#include "global.hpp"
#include "gui/dialogs/loading_screen.hpp"
#include "picture.hpp"
#include "log.hpp"
#include "map/map.hpp"
#include "picture.hpp"
#include "preferences/preferences.hpp"
#include "serialization/string_utils.hpp"
#include "game_config_view.hpp"
static lg::log_domain log_engine("engine");
#define ERR_NG LOG_STREAM(err, log_engine)
@ -770,11 +771,7 @@ terrain_builder::terrain_constraint& terrain_builder::add_constraints(terrain_bu
if(!cons) {
// The terrain at the current location did not exist, so create it
#ifdef __cpp_aggregate_paren_init
constraints.emplace_back(loc);
#else
constraints.push_back({loc});
#endif
constraints.AGGREGATE_EMPLACE(loc);
cons = &constraints.back();
}