How to reorder function parameters?

9

Look at the pseudo-c++ code below:

typedef *** SomeType1;
typedef *** SomeType2;
typedef *** SomeType3;

void BFunc(SomeType1& st1, SomeType2& st2, SomeType3& st3)
{
    /*some work*/;
}

template <typename T1, typename T2, typename T3>
void AFunc(T1& p1, T2& p2, T3& p3)
{
    BFunc(???);
}

There are two functions with parameters. The parameters count larger than three, but for simplicity for example let it would be three.

The Afunc - it is the templated function that have the same parameters count as the BFunc plus the parameters have the same types as the BFunc parameters. But (!) the sequence on the parameters of BFunc can (or cannot) be different. For example:

BFunc(int, double, char)

AFunc<double, int, char>
AFunc<int, double, char>
AFunc<char, double, int>
AFunc<char, int, double>
...

So how to reorder parameters inside AFunc for calling BFunc with correct parameters sequence?

Share
Improve this question
5
  • 4
    Can you elaborate a bit more on why AFunc should be allowed to specify its arguments in any order? Is that flexibility really necessary? – 0x5453 Apr 1 at 15:21
  • 1
    These parameters, are they guaranteed to be unique? ie, BFunc will never have two parameters with the same type? – NathanOliver Apr 1 at 15:27
  • @0x5453, its a long story. I want to add the ability for users of my library to set up lambda-handlers with custom parameters sequence and count. With count I can deal in some way, but with sequence - I dont have any idea how to deal with it. – AeroSun Apr 1 at 15:29
  • @NathanOliver, yes - parameter guaranted to be unique. Yes, BFunc will never have two parameters with same type – AeroSun Apr 1 at 15:30
  • Related to how-to-generate-all-the-permutations-of-function-overloads. – Jarod42 Apr 2 at 9:41

Comments

Popular posts from this blog

Meaning of `{}` for return expression

Get current scroll position of ScrollView in React Native

flutter websocket connection issue