To call the template method in this case, you need to invoke the method explicitly with num(5) instead of num(5). Although the compiler can infer, non-generic method is preferred to a generic one. You can take a look at this behavior here http://ideone.com/ccDJP.