Advertisement
Guest User

Untitled

a guest
Nov 26th, 2012
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <progrock/cppx/macro/nargs.h>          // CPPX_NARGS, CPPX_CONCAT
  2. #include <progrock/cppx/macro/invoke.h>         // CPPX_INVOKE
  3.  
  4. #include <iostream>
  5. using namespace std;
  6.  
  7. #define NUMBER_( x ) x
  8.  
  9. #define NUMBER_1( a ) \
  10.     NUMBER_( a )
  11.  
  12. #define NUMBER_2( a, b ) \
  13.     CPPX_CONCAT( NUMBER_1( a ), NUMBER_( b ) )
  14.  
  15. #define NUMBER_3( a, b, c ) \
  16.     CPPX_CONCAT( NUMBER_2( a, b ), NUMBER_( c ) )
  17.  
  18. #define NUMBER_4( a, b, c, d ) \
  19.     CPPX_CONCAT( NUMBER_3( a, b, c ), NUMBER_( d ) )
  20.  
  21. #define NUMBER_5( a, b, c, d, e ) \
  22.     CPPX_CONCAT( NUMBER_4( a, b, c, d ), NUMBER_( e ) )
  23.  
  24. #define NUMBER( ... )      \
  25.     CPPX_INVOKE( CPPX_CONCAT( NUMBER_, CPPX_NARGS( __VA_ARGS__ ) ), ( __VA_ARGS__ ) )
  26.  
  27. int main()
  28. {
  29.     wcout << NUMBER( 123,456,789 ) << endl;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement