File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,8 +41,11 @@ boost::shared_ptr<AbstractTradeBuilder> TradeFactory::getBuilder(const std::stri
4141void TradeFactory::addBuilder (const std::string& className, const boost::shared_ptr<AbstractTradeBuilder>& builder,
4242 const bool allowOverwrite) {
4343 boost::unique_lock<boost::shared_mutex> lock (mutex_);
44- QL_REQUIRE (builders_.insert (std::make_pair (className, builder)).second || allowOverwrite,
45- " TradeFactory: duplicate builder for className '" << className << " '." );
44+ {
45+ auto [it, ins] = builders_.try_emplace (className, builder);
46+ if (!ins) QL_REQUIRE (allowOverwrite && (it->second = builder),
47+ " TradeFactory: duplicate builder for className '" << className << " '." );
48+ }
4649}
4750
4851boost::shared_ptr<Trade> TradeFactory::build (const string& className) const { return getBuilder (className)->build (); }
You can’t perform that action at this time.
0 commit comments