RAD Studio |  |

E2397: Template argument cannot have static or local linkage (C++)

Only integral constant expressions, and the address of global variables with external linkage, may be used as template arguments. For example:

Copy Code

    template<char *x>
    class foo;
    const char *p = "Hello";
    extern char *q;
    foo<p> x;// OK: "p" is visible to the outside
    foo<q> y;// OK: "q" is also globally visible
    foo<"Hello"> z;// error: string literal has static linkage

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!