C++ 参数列表中的元组

C++ 参数列表中的元组,c++,c++11,variadic-templates,C++,C++11,Variadic Templates,我编写了一个远程调用过程包装器。。 在服务器端,我有一些人类可读的界面,例如: template<typename TBase> class LogicUnit : TBase { public: int getLenFromCalculate( double antenaForce, const std::string & duration) IMPLEMENTATION; float calcSomeAlse( int tableW, float

我编写了一个远程调用过程包装器。。 在服务器端,我有一些人类可读的界面,例如:

template<typename TBase>
class LogicUnit : TBase
{
public:
  int getLenFromCalculate(
    double antenaForce, const std::string & duration) IMPLEMENTATION;

  float calcSomeAlse(
    int tableW, float integral) IMPLEMENTATION;
};
// LogicUnit_c.h
int LogicUnit::getLenFromCalculate( double _1, const std::string & _2 )
{
    return send(__COUNTER__, _1, _2);
}

// LogicUnit_s.h
int LogicUnit::getLenFromCalculate( double antenaForce, const std::string & duration )
{
   return (int)(duration.length() * antenaForce);
}
我的问题是,我可以从ARGS-macros在TUPLE\u中写什么?我想要像下面这样的东西:

define TUPLE_FROM_ARGS send( __FUNCTION__, std::make_tuple( ??????? ) );
或者我如何以另一种方式解决我的问题? 在这个图书馆里
用于创建实现代码的脚本生成器。但我认为,使用模板和宏是否可行。

看起来您正在寻找可变宏:

#define TUPLE_FROM_ARGS( ... ) \
    send( __FUNCTION__, std::make_tuple( __VA_ARGS__ ) );

如果你不清楚自己真正需要什么,就很难给出好的建议。学会写好的。不管怎样,也许你正在寻找这个:

template< typename... Args >
int getLenFromCalculate( Args&&... args )
{
    send( __FUNCTION__, std::make_tuple( std::forward< Args >( args )... ) );
}
模板
int getLenFromCalculate(Args&&…Args)
{
发送(函数,std::生成元组(std::forward(Args)…);
}
(在上面的例子中,我真的不认为需要宏了)

--继续我的问题--

我有班级成员的定义:

class LogicUnit
{
public:
  RPC_FUNC_BEGIN
      int getLenFromCalculate(double antenaForce, const std::string & duration);
  RPC_FUNC_END
};
在客户端,它可能是一些实现,在服务器端,它可能是另一个实现。例如:

template<typename TBase>
class LogicUnit : TBase
{
public:
  int getLenFromCalculate(
    double antenaForce, const std::string & duration) IMPLEMENTATION;

  float calcSomeAlse(
    int tableW, float integral) IMPLEMENTATION;
};
// LogicUnit_c.h
int LogicUnit::getLenFromCalculate( double _1, const std::string & _2 )
{
    return send(__COUNTER__, _1, _2);
}

// LogicUnit_s.h
int LogicUnit::getLenFromCalculate( double antenaForce, const std::string & duration )
{
   return (int)(duration.length() * antenaForce);
}
如果我有很多成员,我将编写下一个look as模板代码:

int Foo::fooBar( double _1, int _2 ) { return send(__COUNTER__, _1, _2); }
void Foo::someQwe( double _1, int _2 ) { return send(__COUNTER__, _1, _2); }
int Foo::getParam( const std::string & _1 ) { return send(__COUNTER__, _1); }
void Foo::beNext( int _1, float _2, SMyStruct _3 ) { return send(__COUNTER__, _1, _2, _3); }
我需要
\uuu PRETTY\u FUNCTION\uuuu
之类的东西:

对于每个函数,我都会复制粘贴参数列表?比如int getLenFromCalculate(双天线力,const std::string&duration){TUPLE_FROM_ARGS(天线力,duration);}float calcSomeAlse(int tableW,float integral){TUPLE_FROM_ARGS(tableW,integral)}e。为此,我需要为代码生成器编写脚本,例如,justuse。