By Anycorn


2010-01-23 19:11:08 8 Comments

Simple question for which I could not find answer on the net. In variadic argument macros, how to find the number of arguments? I am okay with boost preprocessor, if it has the solution.

If it makes a difference, I am trying to convert variable number of macro arguments to boost preprocessor sequence, list, or array for further reprocessing.

11 comments

@Justin 2018-12-20 16:27:54

Boost Preprocessor actually has this as of Boost 1.49, as BOOST_PP_VARIADIC_SIZE(...). It works up to size 64.

Under the hood, it's basically the same as Kornel Kisielewicz's answer.

@Carlo Wood 2019-06-20 18:14:34

Doesn't seem to work for zero arguments.

@Justin 2019-06-20 18:28:56

@CarloWood Indeed. The preprocessor doesn't really have the concept of "zero arguments". What we think of as "zero arguments" is "one empty argument" in the preprocessor. But it's fixable using C++20's __VA_OPT__ or the compiler extensions for ##__VA_ARGS__ removing the previous comma, e.g.: godbolt.org/z/X7OvnK

@matanmarkind 2018-07-24 16:51:50

I'm assuming that each argument to VA_ARGS will be comma separated. If so I think this should work as a pretty clean way to do this.

#include <cstring>

constexpr int CountOccurances(const char* str, char c) {
    return str[0] == char(0) ? 0 : (str[0] == c) + CountOccurances(str+1, c);
}

#define NUMARGS(...) (CountOccurances(#__VA_ARGS__, ',') + 1)

int main(){
    static_assert(NUMARGS(hello, world) == 2, ":(")  ;
    return 0;
}

Worked for me on godbolt for clang 4 and GCC 5.1. This will compute at compile time, but won't evaluate for the preprocessor. So if you are trying to do something like making a FOR_EACH, then this won't work.

@pterodragon 2018-11-30 05:11:00

This answer is underrated. It'll work even for NUMARGS(hello, world = 2, ohmy42, [email protected]#$%^&*()-+=) !!! Each arg string can't have some other symbols like ',' though

@monkey0506 2018-05-11 00:31:42

There are some C++11 solutions for finding the number of arguments at compile-time, but I'm surprised to see that no one has suggested anything so simple as:

#define VA_COUNT(...) detail::va_count(__VA_ARGS__)

namespace detail
{
    template<typename ...Args>
    constexpr std::size_t va_count(Args&&...) { return sizeof...(Args); }
}

This doesn't require inclusion of the <tuple> header either.

@ZDF 2018-05-11 10:36:52

"but why not just use a variadic template and sizeof... instead (as in my own answer)" c++ has become a monster. It has too many features and many of them, like variadic templates, are seldom used. You read about it, you write some examples and then you forget it. Therefore, it is hard to come up with the right idea at the right time. Since your solution seems to be a better option than mine, I will let the natural selection work and I will delete my solution.

@monkey0506 2018-05-11 14:01:47

@ZDF understandable, but I happen to use variadic templates constantly. My programs have become much more robust since C++11, and this is one of the main reasons why. No need to delete your answer though, I think.

@Qwertiy 2018-08-15 23:39:17

It won't work with smth like VA_COUNT(&,^,%). Also, if you are counting via a funtion, I don't see any sence in making a macro.

@ipid 2019-05-18 10:08:45

This solution remains a question: the parameters of VA_COUNT are all identifiers that not yet defined as a variable or something, and it causes error '*** variable is not defined'. Is there any way to fix this?

@Chris Kline 2016-03-15 15:12:46

For convenience, here's an implementation that works for 0 to 70 arguments, and works in Visual Studio, GCC, and Clang. I believe it will work in Visual Studio 2010 and later, but have only tested it in VS2013.

#ifdef _MSC_VER // Microsoft compilers

#   define GET_ARG_COUNT(...)  INTERNAL_EXPAND_ARGS_PRIVATE(INTERNAL_ARGS_AUGMENTER(__VA_ARGS__))

#   define INTERNAL_ARGS_AUGMENTER(...) unused, __VA_ARGS__
#   define INTERNAL_EXPAND(x) x
#   define INTERNAL_EXPAND_ARGS_PRIVATE(...) INTERNAL_EXPAND(INTERNAL_GET_ARG_COUNT_PRIVATE(__VA_ARGS__, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0))
#   define INTERNAL_GET_ARG_COUNT_PRIVATE(_1_, _2_, _3_, _4_, _5_, _6_, _7_, _8_, _9_, _10_, _11_, _12_, _13_, _14_, _15_, _16_, _17_, _18_, _19_, _20_, _21_, _22_, _23_, _24_, _25_, _26_, _27_, _28_, _29_, _30_, _31_, _32_, _33_, _34_, _35_, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, count, ...) count

#else // Non-Microsoft compilers

#   define GET_ARG_COUNT(...) INTERNAL_GET_ARG_COUNT_PRIVATE(0, ## __VA_ARGS__, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
#   define INTERNAL_GET_ARG_COUNT_PRIVATE(_0, _1_, _2_, _3_, _4_, _5_, _6_, _7_, _8_, _9_, _10_, _11_, _12_, _13_, _14_, _15_, _16_, _17_, _18_, _19_, _20_, _21_, _22_, _23_, _24_, _25_, _26_, _27_, _28_, _29_, _30_, _31_, _32_, _33_, _34_, _35_, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, count, ...) count

#endif

static_assert(GET_ARG_COUNT() == 0, "GET_ARG_COUNT() failed for 0 arguments");
static_assert(GET_ARG_COUNT(1) == 1, "GET_ARG_COUNT() failed for 1 argument");
static_assert(GET_ARG_COUNT(1,2) == 2, "GET_ARG_COUNT() failed for 2 arguments");
static_assert(GET_ARG_COUNT(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70) == 70, "GET_ARG_COUNT() failed for 70 arguments");

@Vroomfondel 2018-11-08 21:37:42

IMHO the Microsoft variant fails for zero arguments.

@Chris Kline 2018-11-09 13:13:34

@Vroomfondel the Microsoft variant does work for zero arguments. The very first static_assert in example above is a specific test for the zero-argument case, and I just compiled and ran it on Visual Studio 2017 v15.8.9.

@Vroomfondel 2018-11-09 14:52:03

Interesting - using the the Microsoft variant on a non-Microsoft compiler does not work - do you know what the M$ preprocessor does differently that makes code work the opposite way? BTW I tried C, not C++;

@maciek gajewski 2015-10-26 15:08:15

If you are using C++11, and you need the value as a C++ compile-time constant, a very elegant solution is this:

#include <tuple>

#define MACRO(...) \
    std::cout << "num args: " \
    << std::tuple_size<decltype(std::make_tuple(__VA_ARGS__))>::value \
    << std::endl;

Please note: the counting happens entirely at compile time, and the value can be used whenever compile-time integer is required, for instance as a template parameter to std::array.

@Wim 2016-06-21 09:14:40

Great solution! And unlike sizeof((int[]){__VA_ARGS__})/sizeof(int) suggested above, it works even when the arguments cannot all be cast to int.

@davernator 2019-08-03 20:55:46

Agreed. Great solution! ++.

@elhadi dp ıpɐɥןǝ 2016-03-14 11:58:09

herein a simple way to count 0 or more arguments of VA_ARGS, my exemple assumes a maximum of 5 variables, but you can add more if you want.

#define VA_ARGS_NUM_PRIV(P1, P2, P3, P4, P5, P6, Pn, ...) Pn
#define VA_ARGS_NUM(...) VA_ARGS_NUM_PRIV(-1, ##__VA_ARGS__, 5, 4, 3, 2, 1, 0)


VA_ARGS_NUM()      ==> 0
VA_ARGS_NUM(19)    ==> 1
VA_ARGS_NUM(9, 10) ==> 2
         ...

@AntonK 2018-03-15 11:39:18

Unfortunately the approach works incorrectly when VA_ARGS_NUM is used with macro: if I have #define TEST (i.e. empty TEST) and VA_ARGS_NUM(TEST) doesn't return 0 (zero) when used in #if :(

@elhadi dp ıpɐɥןǝ 2018-03-15 15:51:08

@AntonK can you post what you have done exactly please?

@user1187902 2013-06-04 20:08:59

this works with 0 arguments with gcc/llvm. [links are dumb]

/*
 * we need a comma at the start for ##_VA_ARGS__ to consume then
 * the arguments are pushed out in such a way that 'cnt' ends up with
 * the right count.  
 */
#define COUNT_ARGS(...) COUNT_ARGS_(,##__VA_ARGS__,6,5,4,3,2,1,0)
#define COUNT_ARGS_(z,a,b,c,d,e,f,cnt,...) cnt

#define C_ASSERT(test) \
    switch(0) {\
      case 0:\
      case test:;\
    }

int main() {
   C_ASSERT(0 ==  COUNT_ARGS());
   C_ASSERT(1 ==  COUNT_ARGS(a));
   C_ASSERT(2 ==  COUNT_ARGS(a,b));
   C_ASSERT(3 ==  COUNT_ARGS(a,b,c));
   C_ASSERT(4 ==  COUNT_ARGS(a,b,c,d));
   C_ASSERT(5 ==  COUNT_ARGS(a,b,c,d,e));
   C_ASSERT(6 ==  COUNT_ARGS(a,b,c,d,e,f));
   return 0;
}

Visual Studio seems to be ignoring the ## operator used to consume the empty argument. You can probably get around that with something like

#define CNT_ COUNT_ARGS
#define PASTE(x,y) PASTE_(x,y)
#define PASTE_(x,y) x ## y
#define CNT(...) PASTE(ARGVS,PASTE(CNT_(__VA_ARGS__),CNT_(1,##__VA_ARGS__)))
//you know its 0 if its 11 or 01
#define ARGVS11 0
#define ARGVS01 0
#define ARGVS12 1
#define ARGVS23 2
#define ARGVS34 3

@user720594 2014-12-15 11:15:55

I tested this for Visual Studio 2008 and it did not work for 0 arguments COUNT_ARGS() = 1.

@Jan Smrčina 2016-02-08 17:49:33

The link seems broken.

@user1187902 2016-02-13 02:28:16

fixed link. VS must be doing something different as usual :). I don't think they are going to support C99 fully any time soon.

@Nic Hartley 2017-04-14 18:49:28

Er, ##__VA_ARGS__ eating the comma before if __VA_ARGS__ is empty is a GCC extension. It's not the standard behavior.

@Kornel Kisielewicz 2010-01-23 19:22:50

This is actually compiler dependent, and not supported by any standard.

Here however you have a macro implementation that does the count:

#define PP_NARG(...) \
         PP_NARG_(__VA_ARGS__,PP_RSEQ_N())
#define PP_NARG_(...) \
         PP_ARG_N(__VA_ARGS__)
#define PP_ARG_N( \
          _1, _2, _3, _4, _5, _6, _7, _8, _9,_10, \
         _11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \
         _21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \
         _31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \
         _41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \
         _51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \
         _61,_62,_63,N,...) N
#define PP_RSEQ_N() \
         63,62,61,60,                   \
         59,58,57,56,55,54,53,52,51,50, \
         49,48,47,46,45,44,43,42,41,40, \
         39,38,37,36,35,34,33,32,31,30, \
         29,28,27,26,25,24,23,22,21,20, \
         19,18,17,16,15,14,13,12,11,10, \
         9,8,7,6,5,4,3,2,1,0

/* Some test cases */


PP_NARG(A) -> 1
PP_NARG(A,B) -> 2
PP_NARG(A,B,C) -> 3
PP_NARG(A,B,C,D) -> 4
PP_NARG(A,B,C,D,E) -> 5
PP_NARG(1,2,3,4,5,6,7,8,9,0,
         1,2,3,4,5,6,7,8,9,0,
         1,2,3,4,5,6,7,8,9,0,
         1,2,3,4,5,6,7,8,9,0,
         1,2,3,4,5,6,7,8,9,0,
         1,2,3,4,5,6,7,8,9,0,
         1,2,3) -> 63

@Jasper Blues 2013-01-27 11:29:33

The link is gone now!

@osirisgothra 2014-01-04 09:17:05

....but now is standard in C++0x and should've been longer ago because it allows a great way to guard varadic functions from corrupted calls (ie, you can pass values after the varadic items. This is actually a way of getting the count i used to use, but i guess sizeof could work too..

@ceztko 2014-12-18 00:03:04

The answer links to another site. Also the link doesn't seem to point to the correct answer. And even if I managed to find the intended answer it does seem a poor one as it embeds an hardcoded "-1" that will be compiled. There are better methods.

@mchiasson 2015-06-04 14:13:48

It doesn't seem to work in VS2013 for some reason, and I can't see why it doesn't work. Any idea?

@ceztko 2015-06-04 14:18:31

@mchiasson You may have a look at my complete answer here that comes with 2 versions that will respectively work with msvc and gcc/clang with extensions enabled. They can be easily ifdef-ed for wide compilers support.

@mchiasson 2015-06-04 15:06:44

Thanks! this worked in Visual Studio 2013 for me: #define EXPAND(x) x #define PP_ARG_N(_1,_2,_3,_4,_5,_6,_7,_8,_9,N,...) N #define PP_NARG(...) EXPAND(PP_ARG_N(__VA_ARGS__, 9,8,7,6,5,4,3,2,1,0)) ```

@PSkocik 2016-07-26 11:13:38

PP_NARG() fails to return 0. The GET_ARG_COUNT() & Y_TUPLE_SIZE() solutions work.

@H Walters 2017-06-16 05:13:06

"PP_NARG() fails to return 0" ...isn't necessarily a problem. One can say that PP_NARG() should return 1 for the same reason PP_NARG(,) should return 2. Detecting 0 may indeed be handy in some cases, but the solutions seem to either be less general (requiring that first token to be pasteable; which may or may not be okay depending on what you're using it for), or implementation specific (such as requiring gnu's comma-removing-paste trick).

@Vroomfondel 2018-11-08 21:27:42

@HWalters no, there are solutions without the necessity to concatenate.

@Carlos Leite 2015-03-20 12:15:18

You can stringfy and count tokens:

int countArgs(char *args)
{
  int result = 0;
  int i = 0;

  while(isspace(args[i])) ++i;
  if(args[i]) ++result;

  while(args[i]) {
    if(args[i]==',') ++result;
    else if(args[i]=='\'') i+=2;
    else if(args[i]=='\"') {
      while(args[i]) {
        if(args[i+1]=='\"' && args[i]!='\\') {
          ++i;
          break;
        }
        ++i;
      }
    }
    ++i;
  }

  return result;
}

#define MACRO(...) \
{ \
  int count = countArgs(#__VA_ARGS__); \
  printf("NUM ARGS: %d\n",count); \
}

@J Richard Snape 2015-03-20 16:51:36

Just had a look at the edit pending on this answer - it appears you might have got two accounts. If you stick to one, you'll be able to edit your own posts without it going for approval.

@user720594 2011-04-22 13:47:04

With msvc extension:

#define Y_TUPLE_SIZE(...) Y_TUPLE_SIZE_II((Y_TUPLE_SIZE_PREFIX_ ## __VA_ARGS__ ## _Y_TUPLE_SIZE_POSTFIX,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0))
#define Y_TUPLE_SIZE_II(__args) Y_TUPLE_SIZE_I __args

#define Y_TUPLE_SIZE_PREFIX__Y_TUPLE_SIZE_POSTFIX ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0

#define Y_TUPLE_SIZE_I(__p0,__p1,__p2,__p3,__p4,__p5,__p6,__p7,__p8,__p9,__p10,__p11,__p12,__p13,__p14,__p15,__p16,__p17,__p18,__p19,__p20,__p21,__p22,__p23,__p24,__p25,__p26,__p27,__p28,__p29,__p30,__p31,__n,...) __n

Works for 0 - 32 arguments. This limit can be easily extended.

@osirisgothra 2014-01-04 09:19:01

is it just me or does this kinda break the code smell rules..?

@ThreeBit 2014-03-23 18:53:48

It works for me with VC++ up to at least VS2012, and GCC and clang as well in my basic testing.

@ceztko 2014-11-02 22:59:42

@osirisgothra, exactly why it smells?

@ceztko 2014-12-15 11:23:40

While this macro has wide compilers support, it doesn't work with macro arguments such a string, like Y_TUPLE_SIZE("Hello"), making it quite infeasible. I agree with @osirisgothra.

@user45891 2015-02-28 00:45:39

@ceztko I've just tested it with VS2013 (Version 12.0.21005.1 REL) and that does work (However contrary to ThreeBit's statment it does not seem to work with GCC 4.8.3)

@ceztko 2015-02-28 01:01:54

This macro can work for you but has serious defects. I did a lot of research and found cleaner approaches that work in GCC and VS. You can find them in my answer to a similar question.

@qrdl 2010-01-23 19:41:02

I usually use this macro to find a number of params:

#define NUMARGS(...)  (sizeof((int[]){__VA_ARGS__})/sizeof(int))

Full example:

#include <stdio.h>
#include <string.h>
#include <stdarg.h>

#define NUMARGS(...)  (sizeof((int[]){__VA_ARGS__})/sizeof(int))
#define SUM(...)  (sum(NUMARGS(__VA_ARGS__), __VA_ARGS__))

void sum(int numargs, ...);

int main(int argc, char *argv[]) {

    SUM(1);
    SUM(1, 2);
    SUM(1, 2, 3);
    SUM(1, 2, 3, 4);

    return 1;
}

void sum(int numargs, ...) {
    int     total = 0;
    va_list ap;

    printf("sum() called with %d params:", numargs);
    va_start(ap, numargs);
    while (numargs--)
        total += va_arg(ap, int);
    va_end(ap);

    printf(" %d\n", total);

    return;
}

It is completely valid C99 code. It has one drawback, though - you cannot invoke the macro SUM() without params, but GCC has a solution to it - see here.

So in case of GCC you need to define macros like this:

#define       NUMARGS(...)  (sizeof((int[]){0, ##__VA_ARGS__})/sizeof(int)-1)
#define       SUM(...)  sum(NUMARGS(__VA_ARGS__), ##__VA_ARGS__)

and it will work even with empty parameter list

@Kornel Kisielewicz 2010-01-23 19:50:46

UM, it won't work for the OP, he needs the size for BOOST_PP which runs on compile time.

@Adam Liss 2010-01-23 19:52:31

Clever! Does it also work when sizeof(int) != sizeof(void *) ?

@qrdl 2010-01-23 20:44:18

@Kornel Like any macro, it is evaluated at compile time. I have no idea about Boost, but anyway Boost isn't needed.

@qrdl 2010-01-23 20:45:48

@Adam Because I cast {__VA_ARGS__} to int[], it is just int[], regardless of actual content of __VA_ARGS__

@Kornel Kisielewicz 2010-01-23 21:34:40

@qrdl, so I can write SUM( myfunc(2), myarr[10], 2+3 )?

@qrdl 2010-01-24 07:09:25

@Kornel Of course you can, and it works for both C99 and GCC. Why don't you just try it yourself?

@Frank Jüstel 2013-01-29 19:41:56

you are just a genius :-) Thank's a lot. perfect!

@18446744073709551615 2014-05-15 08:04:13

It will (and did) crash at int main() { return NUMARGS("a",b,c); }

@qrdl 2014-09-24 08:21:37

No, it won't crash - it just doesn't compile. C doesn't allow string literal in integer array

@Buddhika Chaturanga 2015-12-18 09:59:58

In visual studio 2013 - "cast to incomplete array type "int []" is not allowed" I used Visual Studio C compiler.Please help

@qrdl 2015-12-18 15:54:33

@BuddhikaChaturanga How do you call the macro?

@Buddhika Chaturanga 2015-12-20 02:40:22

I tested your example code nothing else.When I compiled it on GCC , code was compiled and ran perfectly,but in visual c/c++ compilers and intel c/c++ compiler(for windows) has given me that compile error.

@qrdl 2015-12-20 07:34:47

@BuddhikaChaturanga Both gcc and clang with -std=c99 -Wpedantic compile it without any errors or warnings, and I believe these are two most standard-compliant compilers, so these should be something wrong with Microsoft's and Intel's compilers

@Buddhika Chaturanga 2015-12-21 04:13:39

Yeah OpenSource-Free stuff are awesome rather than commercial stuff.. I cannot imagine why do they hesitate to maintain full standard ...

@Paul Stelian 2016-12-21 21:49:27

Umm, holy fking st, this one is smart enough and doesn't even need C++, it instead works as C just fine. I needed it for my personal projects so thanks! (whoops, formatting messed up my wording lol)

@AntonK 2018-03-15 11:31:29

Nice approach. Unfortunately it doesn't work when NUMARGS is used in #if :(

@qrdl 2018-03-16 05:28:41

@AntonK What do you mean?

@AntonK 2018-03-27 12:22:49

@qrdl , the code is simple: #if NUMARGS(10) > 0 causes the compile-time error with MSVC++ (VS2017) and gcc (Arduino 1.8.5).

@qrdl 2018-03-27 12:31:33

@AntonK What are you trying to achieve? Looks like XY problem.

@AntonK 2018-03-27 12:35:00

@qrdl, #define VALUE and then #if NUMARGS(VALUE) == 0 to show #error VALUE is not specified

@qrdl 2018-03-27 13:01:58

@AntonK I mean what's the point? Why just don't use #ifndef VALUE? Anyway sizeof is evaluated during the compile time, after the preprocessor, therefore result of sizeof is not available for the preprocessor.

@AntonK 2018-03-27 13:57:15

@qrdl , I was going to detect two cases - one with #define VALUE, and another with #define VALUE 10. Apparently I need another solution for that...

@qrdl 2018-03-27 14:26:21

@AntonK You can use #if VALUE == 10,` NUMARGS()` is for completely different purpose, it isn't a tool for your task

@AntonK 2018-04-03 09:35:30

@qrdl, #if VALUE == 10 causes compile-time error when VALUE is defined without a value (i.e. #define VALUE)

@poby 2018-10-07 02:24:41

Elegant solution! Works in VS2017. The ## isn't needed in VS2017 as an empty __VA_ARGS__ will automatically remove any preceding comma.

@chux 2019-01-03 15:19:36

Any reason for int vs char to drop the /sizeof(int)) and then have (sizeof((char[]){__VA_ARGS__}))?

@qrdl 2019-01-03 17:31:38

@chux Nope, should work the same. But probably some compilers will throw warnings about attempts to fit int into char. GCC is fine with char, even with -Wall -Wextra. It just didn't occur to me that it can be simplified. Thanks!

Related Questions

Sponsored Content

1 Answered Questions

[SOLVED] The Definitive C++ Book Guide and List

  • 2008-12-23 05:23:56
  • grepsedawk
  • 2202843 View
  • 4247 Score
  • 1 Answer
  • Tags:   c++ c++-faq

37 Answered Questions

10 Answered Questions

[SOLVED] Improve INSERT-per-second performance of SQLite?

13 Answered Questions

[SOLVED] What is the effect of extern "C" in C++?

21 Answered Questions

[SOLVED] What is the "-->" operator in C++?

24 Answered Questions

[SOLVED] Image Processing: Algorithm Improvement for 'Coca-Cola Can' Recognition

19 Answered Questions

10 Answered Questions

[SOLVED] Standard alternative to GCC's ##__VA_ARGS__ trick?

10 Answered Questions

5 Answered Questions

[SOLVED] Why does the C preprocessor interpret the word "linux" as the constant "1"?

Sponsored Content