Boost logo

Boost :

From: Mike (mike.dev_at_[hidden])
Date: 2020-08-23 18:34:54


> Gesendet: Sonntag, 23. August 2020 um 19:09 Uhr
> Von: "Zach Laine via Boost" <boost_at_[hidden]>
> An: "Boost mailing list" <boost_at_[hidden]>
> Cc: "Zach Laine" <whatwasthataddress_at_[hidden]>
> Betreff: Re: [boost] Modules
>
> On Sun, Aug 23, 2020 at 2:13 AM Mike via Boost <boost_at_[hidden]> wrote:
> >
> > > Gesendet: Sonntag, 23. August 2020 um 00:40 Uhr
> > > Von: "Zach Laine via Boost" <boost_at_[hidden]>
> > > An: "Boost mailing list" <boost_at_[hidden]>
> > > Cc: "Zach Laine" <whatwasthataddress_at_[hidden]>
> > > Betreff: Re: [boost] Modules
> > >
> > > On Fri, Aug 21, 2020 at 1:54 PM Damian Vicino via Boost
> > > <boost_at_[hidden]> wrote:
> > > >
> > > > Hi,
> > > > Are there any guidelines on the use of modules inside boost?
> > > > Are we planning any steps for adoption of them?
> > >
> > > Modules are pretty hard for most Boost libs to adopt. Consider how
> > > many times we have code like this:
> > >
> > > #if BOOST_LIBNAME_DO_WHATEVER
> > > some_code;
> > > #else
> > > come_other_code;
> > > #endif
> > >
> > > That cannot exist inside a module. The net result is that your code
> > > has to be all the same lexically -- for all compilers and platforms --
> > > if it is in a module.
> >
> > Are you sure? I've never hear of such a restriction.
>
> Yes, although it may not be clear what I mean. You can only have
> preprocessor directives before the keyword module:
>
> #ifdef SOMETHING // ok
> #include "foo.h" // ok
> #endif // ok
>
> module foo;
>
> #ifdef SOMETHING // error
> #include "bar.h" // error
> #endif // error

Could you maybe point me to the relevant location in the standard? A quick test with
compiler explorer (https://godbolt.org/z/EP18s1) turns not up any errors,
but of course I doubt any compiler implements modules completely to spec yet.

> [...]
>
> > However, you should be able to do the same as other legacy libraries: Make sure your headers can be used as header units and/or provide a wrapper module for each library.
>
> Right, it's just that if you have lots of code in common, but just
> want it to vary a bit, you have to put that code in the module prefix
> and then export it from the module. It's not the end of the world,
> but it is anti-idiomatic to all teaching you're likely to see about
> how to write modules.

Not sure to which of the two suggestions you are replying, but I really
don't understand why it should require any work for most of boost
(except maybe the PP library) to be consumable as a header unit.
And for a wrapper module, what I have in mind is something like:

module;
#include <boost/variant.hpp>
export module Boost.Variant;

namespace boost {
    export using boost::variant;
}

But I'm absolutely no modules expert.

Mike

>
> Zach
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk