fork download
  1. #include <iostream>
  2.  
  3. #include <boost/preprocessor/repetition/enum.hpp>
  4.  
  5. #define VALUE(z, n, text) f(n)
  6.  
  7. int f(int x) { return x * 10; }
  8.  
  9. int main() {
  10. int const a[] = { BOOST_PP_ENUM(10, VALUE, ~) }; //N = 10
  11. std::size_t const n = sizeof(a)/sizeof(int);
  12. std::cout << "count = " << n << "\n";
  13. for(std::size_t i = 0 ; i != n ; ++i )
  14. std::cout << a[i] << "\n";
  15. return 0;
  16. }
Success #stdin #stdout 0.02s 2724KB
stdin
Standard input is empty
stdout
count = 10
0
10
20
30
40
50
60
70
80
90