Added workaround for limitation in GCC 8.0
Added workaround for limitation in GCC 8.0

It seems that GCC 8.0 doesn't support lambda expressions in template parameters.

- Moved evaluation of current counter into a separate constexpr variable, which is subsequently used in the template parameter.

erikvalkering/smartref,erikvalkering/smartref,erikvalkering/smartref