variadic

CPP/GPP in Fortran variadic macro (plus Fortran // concatenation)

筅森魡賤 提交于 2019-12-20 01:04:54
问题 I'm trying to compile a huge, world-renowned numerical weather prediction code - written mostly in Fortran 90 - that uses cpp extensively, and successfully, with PGI, Intel and gfortran. Now, I've inherited a version where experts have added several hundred cases of variadic macros. They use Intel and fpp , which is presumably a little more Fortran-centric, and can get it all to work. I need to use gfortran, and have not been able to get cpp to work on this code with its new additions. A

CPP/GPP in Fortran variadic macro (plus Fortran // concatenation)

青春壹個敷衍的年華 提交于 2019-12-20 01:03:15
问题 I'm trying to compile a huge, world-renowned numerical weather prediction code - written mostly in Fortran 90 - that uses cpp extensively, and successfully, with PGI, Intel and gfortran. Now, I've inherited a version where experts have added several hundred cases of variadic macros. They use Intel and fpp , which is presumably a little more Fortran-centric, and can get it all to work. I need to use gfortran, and have not been able to get cpp to work on this code with its new additions. A

CPP/GPP in Fortran variadic macro (plus Fortran // concatenation)

我的未来我决定 提交于 2019-12-20 01:03:07
问题 I'm trying to compile a huge, world-renowned numerical weather prediction code - written mostly in Fortran 90 - that uses cpp extensively, and successfully, with PGI, Intel and gfortran. Now, I've inherited a version where experts have added several hundred cases of variadic macros. They use Intel and fpp , which is presumably a little more Fortran-centric, and can get it all to work. I need to use gfortran, and have not been able to get cpp to work on this code with its new additions. A

Can variadic expansions be used as a chain of comma-operator calls?

柔情痞子 提交于 2019-12-19 03:43:07
问题 I was looking at "How to properly use references with variadic templates," and wondered how far comma expansion can go. Here's a variant of the answer: inline void inc() { } template<typename T,typename ...Args> inline void inc(T& t, Args& ...args) { ++t; inc(args...); } Since variadic arguments are expanded to a comma -separated list of their elements, are those commas semantically equivalent to template/function-argument separators, or are they inserted lexically , making them suitable for

Is Boost.Tuple compatible with C++0x variadic templates?

非 Y 不嫁゛ 提交于 2019-12-18 17:03:37
问题 I was playing around with variadic templates (gcc 4.5) and hit this problem : template <typename... Args> boost::tuple<Args...> my_make_tuple(Args... args) { return boost::tuple<Args...>(args...); } int main (void) { boost::tuple<int, char> t = my_make_tuple(8, 'c'); } GCC error message : sorry, unimplemented: cannot expand 'Arg ...' into a fixed-length argument list In function 'int my_make_tuple(Arg ...)' If I replace every occurrence of boost::tuple by std::tuple , it compiles fine. Is

C++ overloading operator comma for variadic arguments

孤街醉人 提交于 2019-12-18 16:54:44
问题 is it possible to construct variadic arguments for function by overloading operator comma of the argument? i want to see an example how to do so.., maybe something like this: template <typename T> class ArgList { public: ArgList(const T& a); ArgList<T>& operator,(const T& a,const T& b); } //declaration void myFunction(ArgList<int> list); //in use: myFunction(1,2,3,4); //or maybe: myFunction(ArgList<int>(1),2,3,4); 回答1: It is sort-of possible, but the usage won't look very nice. For exxample:

Creating a string list and an enum list from a C++ macro

安稳与你 提交于 2019-12-17 23:27:31
问题 In order to make my code shorter and easier to change I want to replace something like enum{ E_AAA, E_BBB, E_CCC }; static const char *strings{"AAA", "BBB", "CCC" }; With a macro, like INIT(AAA, BBB, CCC); but when I try doing a macro with variable arguments, and stringification I get an error as the arguments are not declared. Any idea on how to do this? 回答1: Here a solution I learned a few days ago. The simplified version that attends your question is: #define ENUM_MACRO(name, v1, v2, v3,

Calling Objective-C initializer with variadic arguments

别来无恙 提交于 2019-12-14 02:49:49
问题 I'm trying to re-use an Objective-C class, namely TSAlertView, into a Swift project. The problem is that the class uses an initializer with variadic arguments. I followed the same approach suggested at this stackoverflow question and my code works in the iOS Simulator if I use the iPad Air but NOT if I use the iPad Retina. The code also crashes on a real iPad 3. I was able to create a toy example that shows the same issue. TestClass.h #import <Foundation/Foundation.h> @interface TestClass :

Passing variable arguments in a C++ variadic template

佐手、 提交于 2019-12-13 12:44:17
问题 Say I have a template function that accepts variable arguments and calls other functions with those arguments... template<typename... A> func(int i, A... args) { // do something common switch (i) { case 0: x(args...); break; case 1: y(args...); break; case 2: z(args...); break; default: break; } // do something common } ...and the other functions are defined as... void x(int a, int b); void y(int a, int b); // note: takes same args as x() void z(std::string a); This doesn't compile because

How to convert a #define in a template (variadic?)

不问归期 提交于 2019-12-13 08:33:55
问题 I've two macros and I desire to convert them in C++ templates. I've problems in understendig how to convert them. Here are the two macros: #define __MATRIX_GETVALUE(C,T,val,dim0...) \ va_list vl; \ va_start(vl,dim0); \ C->setPositions(vl,dim0); va_end(vl);\ val = *((T *)(m_values)+posInValueVector()) #define __MATRIX_SETVALUE(C,T,val,dim0...) \ va_list vl; \ va_start(vl,dim0); \ C->setPositions(vl,dim0); va_end(vl);\ *((T *)(m_values)+posInValueVector())=val The two macros above are used in