|
Boost : |
Subject: Re: [boost] How best to implement a bitfield in C++ 14?
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2016-02-05 04:29:50
On 5 Feb 2016 at 4:50, Gottlob Frege wrote:
> Well, you could still pass flag::none - the function address - to
> flag::operator&().
> But of course you could then pass any function - with the same signature -
> so none() might need a signature like none(some_special_type unused = 0) to
> prevent mistaken misuse.
>
> Does that help?
I thought of this too (specifically some_special_type<bits set for
this flag>), but I realised I was getting into metaprogramming land.
I'm sure a "perfect" typesafe bitfield can finally be implemented as
of C++ 14, but I think the likely implementation should be submitted
as a N-paper to WG21 as an excellent example of what needs to be
fixed in the C++ language. After all, typesafe bitfields ought to in
a systems programming language!
A conference talk on building one of these might be very interesting
... nudge nudge! :)
Niall
-- 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