[Solved] How not to ignore the spaces that precede constructor arguments?


What you ‘re trying to do is impossible since you don’t have any control on the C++ parser and honestly makes no sense for anyone who will use your code.

Unless you write some kind of preprocessor (just don’t), best option here is just to add zeros wherever is necessary:

SparseArray<double, 10> array1( 0, 4.0, 0, 7.0);

If you still want to use whitespaces, an alternative is to use string as argument and then parse it yourself, extracting numbers and finding whitespaces:

SparseArray<double, 10> array1("   4.0,   7.0");

I would go with the first option.

solved How not to ignore the spaces that precede constructor arguments?