xte::init_list<>

Defined in header <xte/util/init_list.hpp>

A wrapper for std::initializer_list {}, allowing its elements to be moved from.


Definition

template<typename T>
using init_list = std::initializer_list</* ... */>;



Example

struct ptr_array {
	std::vector<std::unique_ptr<int>> data;

	ptr_array(xte::init_list<std::unique_ptr<int>> init_list) {
		for (auto&& item : init_list) {
			this->data.push_back(std::move(item));
		}
	}
};

ptr_array a = {
	std::make_unique<int>(1),
	std::make_unique<int>(2),
	std::make_unique<int>(3)
};
[View in Compiler Explorer]