Search Results

Search found 1 results on 1 pages for 'pezcode'.

Page 1/1 | 1 

  • Deduce non-type template parameter

    - by pezcode
    Is it possible to deduce a non-type template parameter from a template function parameter? Consider this simple template: template <int N> constexpr int factorial() { return N * factorial<N - 1>(); } template <> constexpr int factorial<0>() { return 1; } template <> constexpr int factorial<1>() { return 1; } I would like to be able to change factorial so that I can alternatively call it like this: factorial(5); and let the compiler figure out the value of N at compile time. Is this possible? Maybe with some fancy C++11 addition?

    Read the article

1