Subject: Re: [boost] [type_traits] Rewrite and dependency free version
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2015-02-03 19:14:46
On 3 Feb 2015 at 14:20, Matt Calabrese wrote:
> > For the record, you can simulate clang's modules using any compiler
> > by simply compiling in everything as a single translation unit. A
> > simple shell script can create a file which includes all the source
> > files at once.
> > If it works as a single translation unit, it'll work under clang
> > modules. If it doesn't, well then you've got some ODR violation going
> > on (very common in source files which assume they own their
> > translation unit) and it may or may not work under clang modules
> > depending.
> Wait, I'm confused... is this actually true? Maybe I'm missing something,
> but I can imagine a simple example of an anonymous namespace in two
> translation units that define similar functions (i.e. each would have been
> defined and used in their own cpp in the multi-translation-unit version).
> This is not an ODR violation but it would fail compilation if done as you
> suggest. I'm not very familiar with modules as they are currently, but it
> seems like the assertion must be erroneous.
That is a very good point.
Ok, as I said before, but excluding anonymous namespaces. I never use
anonymous namespaces in my own code, and so never encountered that
problem. I'd imagine a macro concatenating __COUNTER__ solution with
inline namespaces could let you work around anonymous namespace
collision. Or else just remove and name them explicitly, or make them
named and inline.
(BTW I am actually fairly sure clang's C++ Modules support currently
doesn't understand anonymous namespaces, and in fact I am right
unintentionally. But if so I am right through accident, not design).
-- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk