Originally Posted by ISO/IEC 14882:2003(E) Footnote of 7.3.1.1.2
Gotta love that C++ standardOriginally Posted by ISO/IEC 14882:2003(E) 2.1
This is a discussion on template constructor within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by ISO/IEC 14882:2003(E) Footnote of 7.3.1.1.2 82) Although entities in an unnamed namespace might have external linkage, they ...
Originally Posted by ISO/IEC 14882:2003(E) Footnote of 7.3.1.1.2
Gotta love that C++ standardOriginally Posted by ISO/IEC 14882:2003(E) 2.1
Lets see here:
Originally Posted by 14.1.1
Originally Posted by 14.1.3
Originally Posted by 14.1.4
Theres more but I really don't feel like quoting the entire 14.1 sectionOriginally Posted by 14.1.5-14.1.7
so82) Although entities in an unnamed namespace might have external linkage
the buffer has external linkage, because no static specifiedCode:namespace{ char buffer[256]; }
so
X<buffer> is correct.
Nana C++ Library is a GUI framework that designed to be C++ style, cross-platform and easy-to-use.
Its not really external linkage as no one outside of the translation unit can get to that variable.
Try this:
file1.c
file2.cCode:namespace { char buffer[256]; };
And tell me if that works.Code:extern buffer; X<buffer>
an unnamed namespace is the new way of saying the deprecated static. Anything in an unnamed namespace is only available to that translation unit in which the namespace is declared therefore linkage is internal.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
to Thantos:
take a look at this code
back to your codeCode://file.cpp namespace { char buffer_external[256]; //external linkage static char buffer_internal[256]; //internal linkage }; template<char* P> class X{}; int main() { X<buffer_external> x; //it's OK, X<buffer_internal> y; //error, buffer_internal has not external linkage }
now, definition of x is failed, because buffer is in an unnamed namespace and in onther translation unit. but it does not indicate buffer has internal linkage, it still has external linkage, it just says buffer is not available to that translationCode://file1.c namespace { char buffer[256]; }; //file2.c extern buffer; X<buffer> x;
refer to
Although entities in an unnamed namespace might have external linkage, they are effectively qualified by a name unique to their translation unit and therefore can never be seen from any other translation unit.
Nana C++ Library is a GUI framework that designed to be C++ style, cross-platform and easy-to-use.
Since you won't listen to me:
So if you can't name it in another translational unit then its not external linkage. But don't take my word for it:Originally Posted by 3.5.1
Note: All bolding mineOriginally Posted by 3.5.4
refer to
what about this codeOriginally Posted by 14.3.2
A template-argument for a non-type, non-template template-parameter shall be one of;
- an integral constant-expression of integral or enumeration type; or
- the name of a non-type template-parameter; or
- the name of an object or function with external linkage, including function templates and function template-ids but excluding non-static class members. expressed as & id-expression where the & is optional if the name refers to a function or array; or
- a pointer to member expressed as described in 5.3.1
if buffer_external has internal linkage, how can be X<buffer_external> legal ?Code:namespace { char buffer_external[256]; //external linkage static char buffer_internal[256]; //internal linkage }; template<char* P> class X{}; int main() { X<buffer_external> x; //it's OK, X<buffer_internal> y; //error, buffer_internal has not external linkage }
an unnamed namespace restricts the visibility of its members to the scope of the translation unit by means of name mangling, it doesn't necessarily guarantee internal linkage
Nana C++ Library is a GUI framework that designed to be C++ style, cross-platform and easy-to-use.
I'm done with this. Anyone else want to try?
nah not worth the energy.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi