For example, I have a class Point
and has a function
void foo(Point pt);
call it as
foo({1, 2, 3});
#include <initializer_list>
#include <cassert>
struct bar
{
void foo(const std::initializer_list<int>& bits)
{
assert(bits.size() == 3);
auto i = bits.begin();
x = *i++;
y = *i++;
z = *i++;
}
int x, y, z;
};
int main()
{
bar b;
b.foo({0, 1, 2});
}