Grid template

The logic is the same, but the API changes because of the template, and some code has been moved from implementation to header files.
If there is no source file, then there is no need for a library. CMake will strip all headers and build an empty lib if you leave this rule. It should be removed entirely.