I have below code snippet.
--- CODE START ------
#include<iostream>
namespace {
int p;
}
static int i;
template<const int& T> struct Sample { };
using namespace std;
int main(int argc,char* argv[]) {
Sample<p> o1; // works although internal linkage as per c++ reference.
Sample<i> o2; // error because static variable has internal linkage and
Template argument initialization requires external linkage.
}
--- CODE END ------
ibm c++ reference says that unnamed namespace variables have internal
linkage hence better to use than static variables. - (A)
http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=%2F
com.ibm.xlcpp8a.doc%2Flanguage%2Fref%2Funnamed_namespaces.htm
also i verified via g++ as well as Microsoft compiler that "template
arguments cannot be names with internal linkage" - (B)
( also verified via below link )
http://www.comeaucomputing.com/techtalk/#nostatic
so if above code does not work Which of above statements is incorrect (A) or
(B) ?
--
[ See
http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]