c++14 - C++ function argument safety -


in function takes several arguments of same type, how can guarantee caller doesn't mess ordering?

for example

void allocate_things(int num_buffers, int pages_per_buffer, int default_value ... 

and later

// uhmm.. lets see which uhh.. allocate_things(40,22,80,... 

a typical solution put parameters in structure, named fields.

allocateparams p; p.num_buffers = 1; p.pages_per_buffer = 10; p.default_value = 93; allocate_things(p); 

you don't have use fields, of course. can use member functions or whatever like.


Comments