c++ varargs/variadic function with two types of arguments that repeat together (alternating)

  c++, variadic-functions, variadic-templates

I can find examples of how to write variadic functions with one type that repeats like StringFormat() but I need to write one where two different types repeat alternating.

The usage needs to look like this:

MyFunc(stringVar, intVar1, doubleVar1);
MyFunc(stringVar, intVar1, doubleVar1, intVar2, doubleVar2, intVar3, doubleVar3, intVar4, doubleVar4);

where the function always has a string input and a minimum of one int and one double but where the int and double would repeat together.

If possible I also need a way to have the documentation tell you which arg type you’re on. Maybe the documentation generates automatically and just works but just in case there’s something special you need to do please include that too or if it’s not possible to have intellisense work for that please let me know. Something like this maybe: ???

/// <summary>
/// MyFunc Summary
/// </summary>
/// <param name="name">Name description</param>
/// <param name="event1_id">ID for Event 1</param>
/// <param name="event1_value">Value for Event 1</param>
/// ...
/// <param name="eventN_id">ID for Event N</param>
/// <param name="eventN_value">Value for Event N</param>
/// <returns>return description</returns>

Source: Windows Questions C++

LEAVE A COMMENT