标准N3242(C++11草案)和N3797(C++14draft)两者有相同的段落。§3.5Programandlinkage[basic.link]¶6Thenameofafunctiondeclaredinblockscopeandthenameofavariabledeclaredbyablockscopeexterndeclarationhavelinkage.Ifthereisavisibledeclarationofanentitywithlinkagehavingthesamenameandtype,ignoringentitiesdeclaredoutsidethei
我有一些非常简单的(C++11)代码,最新的clang(version3.4trunk187493)无法编译,但GCC编译正常。代码(下面)实例化函数模板foo使用局部函数类型Bar然后尝试将其地址用作类模板Func的非类型模板参数:templatestructFunc{};templateexterninlinevoidfoo(){usingFoo=Func>;}intmain(){structBar{};//function-localtypefoo();return0;}clang发出以下错误:error:non-typetemplateargumentreferstofunct
假设我们有一个标题foo.h包含以下内容:#ifndefFOO_H_#defineFOO_H_namespacefoo{constexprstd::string_viewkSomeString="blah";}#endif//FOO_H_foo::kSomeString是否保证在包含foo.h的任何翻译单元中具有内部链接?这在C++11和C++17之间是否有所不同?在标准草案中[basic.link]/3说Anamehavingnamespacescopehasinternallinkageifitisthenameof[...]anon-inlinevariableofnon-vol