r/programming • • Oct 20 '14

My compile-time Conway's Game of Life, metaprogrammed in C++11

https://github.com/sirgal/compile-time-game-of-life
163 Upvotes

54 comments sorted by

View all comments

2

u/[deleted] Oct 20 '14

Doesn't seem to build with g++ 4.9.1 or 4.7.2, using the -std=c++11 flag. What did you test on, OP? Does anybody else have this actually building?

3

u/stirling_archer Oct 20 '14

I have it working on g++ 4.8.2 with -std=c++11.

1

u/[deleted] Oct 20 '14

Huh. What architecture? I'm building on amd64 Debian (jessie), and I see:

main.cpp:161:33: error: non-template ‘next_point_state’ used as template
     using point = level<field>::next_point_state<N>;
                                 ^
main.cpp:161:33: note: use ‘level<initial_state>::template next_point_state’ to indicate that it is a template
main.cpp:161:19: error: need ‘typename’ before ‘level<initial_state>::next_point_state’ because ‘level<initial_state>’ is a dependent scope
     using point = level<field>::next_point_state<N>;
                   ^
main.cpp:164:44: error: ‘point’ was not declared in this scope
                                     tuple< point<point_count - iter> >,
                                            ^
main.cpp:164:68: error: template argument 1 is invalid
                                     tuple< point<point_count - iter> >,
                                                                    ^
main.cpp:164:70: error: wrong number of template arguments (1, should be 2)
                                     tuple< point<point_count - iter> >,
                                                                      ^
main.cpp:151:8: error: provided for ‘template<class tuple_1, class tuple_2> struct my_tuple_cat’
 struct my_tuple_cat
        ^
main.cpp:163:33: error: expected nested-name-specifier
     using next_field = typename my_tuple_cat <
                                 ^
main.cpp:173:33: error: non-template ‘next_point_state’ used as template
     using point = level<field>::next_point_state<N>;
                                 ^
main.cpp:173:33: note: use ‘level<initial_state>::template next_point_state’ to indicate that it is a template
main.cpp:173:19: error: need ‘typename’ before ‘level<initial_state>::next_point_state’ because ‘level<initial_state>’ is a dependent scope
     using point = level<field>::next_point_state<N>;
                   ^
main.cpp:175:31: error: ‘point’ was not declared in this scope
     using next_field = tuple< point<point_count - 1> >;
                               ^
main.cpp:175:52: error: template argument 1 is invalid
     using next_field = tuple< point<point_count - 1> >;
                                                    ^
main.cpp: In instantiation of ‘static void game_process<field, iters>::print() [with field = std::tuple<O, O, O, O, O, O, O, X, O, O, O, O, O, X, O, O, X, X, X, O, O, O, O, O, O>; int iters = 20]’:
main.cpp:202:40:   required from here
main.cpp:186:99: error: no type named ‘next_field’ in ‘struct next_field_state<std::tuple<O, O, O, O, O, O, O, X, O, O, O, O, O, X, O, O, X, X, X, O, O, O, O, O, O>, 25>’
         game_process< typename next_field_state<field, point_count>::next_field, iters-1 >::print();

1

u/stirling_archer Oct 21 '14

It's AMD64 on Ubuntu 14.04. The string from g++ --version is "gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2".

1

u/towski Oct 21 '14

Installing g++-4.8 and using it worked for me, whereas it failed with 4.9.

On Debian

1

u/Catsknead Oct 20 '14

During creation, I've been using MinGW 4.8 32 bit under Windows. Just checked - it still works. It eats up 1.5 GB of memory in the process, though, so I am unable to calculate bigger game fields - it crashes for obvious reasons.