I have tried to use this suggestion to do a static assert, but I do not get a compilation error if I use it within a method of a template.
The example follows :
If you add call to the method in question (a.foo();), the static assert will fail (just then the method will be compiled). You do know that you should not static assert on run time values like "k" I presume.