Return pair<iterator,bool> from flat_set::emplace.
This commit is contained in:
		
							parent
							
								
									ccd04b98b9
								
							
						
					
					
						commit
						f133dd396c
					
				
					 3 changed files with 17 additions and 13 deletions
				
			
		| 
						 | 
					@ -602,36 +602,38 @@ public:
 | 
				
			||||||
	using parent::contains;
 | 
						using parent::contains;
 | 
				
			||||||
	using parent::erase;
 | 
						using parent::erase;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	iterator insert(const Type &value) {
 | 
						std::pair<iterator, bool> insert(const Type &value) {
 | 
				
			||||||
		if (this->empty() || this->compare()(value, this->front())) {
 | 
							if (this->empty() || this->compare()(value, this->front())) {
 | 
				
			||||||
			this->impl().push_front(value);
 | 
								this->impl().push_front(value);
 | 
				
			||||||
			return this->begin();
 | 
								return std::make_pair(this->begin(), true);
 | 
				
			||||||
		} else if (this->compare()(this->back(), value)) {
 | 
							} else if (this->compare()(this->back(), value)) {
 | 
				
			||||||
			this->impl().push_back(value);
 | 
								this->impl().push_back(value);
 | 
				
			||||||
			return (this->end() - 1);
 | 
								return std::make_pair(this->end() - 1, true);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		auto where = this->getLowerBound(value);
 | 
							auto where = this->getLowerBound(value);
 | 
				
			||||||
		if (this->compare()(value, *where)) {
 | 
							if (this->compare()(value, *where)) {
 | 
				
			||||||
			return this->impl().insert(where, value);
 | 
								return std::make_pair(this->impl().insert(where, value), true);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return this->end();
 | 
							return std::make_pair(where, false);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	iterator insert(Type &&value) {
 | 
						std::pair<iterator, bool> insert(Type &&value) {
 | 
				
			||||||
		if (this->empty() || this->compare()(value, this->front())) {
 | 
							if (this->empty() || this->compare()(value, this->front())) {
 | 
				
			||||||
			this->impl().push_front(std::move(value));
 | 
								this->impl().push_front(std::move(value));
 | 
				
			||||||
			return this->begin();
 | 
								return std::make_pair(this->begin(), true);
 | 
				
			||||||
		} else if (this->compare()(this->back(), value)) {
 | 
							} else if (this->compare()(this->back(), value)) {
 | 
				
			||||||
			this->impl().push_back(std::move(value));
 | 
								this->impl().push_back(std::move(value));
 | 
				
			||||||
			return (this->end() - 1);
 | 
								return std::make_pair(this->end() - 1, true);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		auto where = this->getLowerBound(value);
 | 
							auto where = this->getLowerBound(value);
 | 
				
			||||||
		if (this->compare()(value, *where)) {
 | 
							if (this->compare()(value, *where)) {
 | 
				
			||||||
			return this->impl().insert(where, std::move(value));
 | 
								return std::make_pair(
 | 
				
			||||||
 | 
									this->impl().insert(where, std::move(value)),
 | 
				
			||||||
 | 
									true);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return this->end();
 | 
							return std::make_pair(where, false);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	template <typename... Args>
 | 
						template <typename... Args>
 | 
				
			||||||
	iterator emplace(Args&&... args) {
 | 
						std::pair<iterator, bool> emplace(Args&&... args) {
 | 
				
			||||||
		return this->insert(Type(std::forward<Args>(args)...));
 | 
							return this->insert(Type(std::forward<Args>(args)...));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -83,7 +83,8 @@ int MessagesList::addRangeItemsAndCountNew(
 | 
				
			||||||
		std::end(messages) };
 | 
							std::end(messages) };
 | 
				
			||||||
	auto slice = _slices.emplace(
 | 
						auto slice = _slices.emplace(
 | 
				
			||||||
		std::move(sliceMessages),
 | 
							std::move(sliceMessages),
 | 
				
			||||||
		noSkipRange);
 | 
							noSkipRange
 | 
				
			||||||
 | 
						).first;
 | 
				
			||||||
	update.messages = &slice->messages;
 | 
						update.messages = &slice->messages;
 | 
				
			||||||
	update.range = slice->range;
 | 
						update.range = slice->range;
 | 
				
			||||||
	return slice->messages.size();
 | 
						return slice->messages.size();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -84,7 +84,8 @@ SparseIdsList::AddResult SparseIdsList::addRangeItemsAndCountNew(
 | 
				
			||||||
		std::end(messages) };
 | 
							std::end(messages) };
 | 
				
			||||||
	auto slice = _slices.emplace(
 | 
						auto slice = _slices.emplace(
 | 
				
			||||||
		std::move(sliceMessages),
 | 
							std::move(sliceMessages),
 | 
				
			||||||
		noSkipRange);
 | 
							noSkipRange
 | 
				
			||||||
 | 
						).first;
 | 
				
			||||||
	update.messages = &slice->messages;
 | 
						update.messages = &slice->messages;
 | 
				
			||||||
	update.range = slice->range;
 | 
						update.range = slice->range;
 | 
				
			||||||
	const auto count = int(slice->messages.size());
 | 
						const auto count = int(slice->messages.size());
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue