I want to emplace an object into a std::map whose constructor does not take any arguments. However, std::map::emplace seems to require at least one
std::map
std::map::emplace
You could explicitly create a pair and pass that to map::emplace, or use the piecewise construction constructor of std::pair.
pair
map::emplace
std::pair
struct foo {}; std::map m; m.emplace(std::pair(1, {})); m.emplace(std::piecewise_construct, std::forward_as_tuple(2), std::forward_as_tuple());
Live demo