
On 2/27/2013 4:25 AM, John Maddock wrote:
At least one other compiler does in fact require the bare definition to link properly, and doesn't generate it automatically as an enhancement. So I need to make these definitions conditional based on the platform (and perhaps the exact compiler version? That's why I like to use the existing config knowledge base!)
I see that Boost has BOOST_STATIC_CONSTANT but that is for compilers that don't have the in-class initialization at all.
So if Boost is using such constructs, how does it deal with the linker idiosyncrasy?
You could always not initialize inline and therefore always supply a separate definition.
Which would prevent them being used as constant-expressions?
I see your point. But in the worst case you could always put your static const declarations in a header file within a namespace rather than in a class. Then just include the header file as needed. This would solve the anomalies between compilers. I agree it would be better and more natural using whatever Boost could provide as a solution rather than twist your code to workaround compiler differences.