BitArray/BitFields - Reworking with templates
Dmitry Olshansky
dmitry.olsh at gmail.com
Mon Jul 30 14:56:15 PDT 2012
On 31-Jul-12 01:03, Era Scarecrow wrote:
> On Monday, 30 July 2012 at 20:19:51 UTC, Dmitry Olshansky wrote:
>> Not sure what you would like to accomplish here.
>
> Than an example...
>
You can go for simpler separation:
struct BitArray{
//() - is an empty template spec
ref BitArrayopSliceAssign()(const BitArray ba, int start, int end)
{
//two bit array can try balk mode etc.
> Reminds me. Due to how rvalue/lvalues work, assuming I need to const
> reference something but I don't care if it's a temporary or not, would I
> then do...
>
> struct X {
> int opCmp(const X x) const { //catch temporary
> return opCmp(x); //becomes reference, as it's now named 'x'
> }
> int opCmp(const ref X x) const {
> //do work here
> return 0;
> }
> }
>
> X x;
> assert(x == x); //ref
> assert(x == X()); //temporary
>
> course if the 'in' keyword is the key i will have to test that to make
> sure.
in == scope const not sure what scope buys here but couldn't hurt.
--
Dmitry Olshansky
More information about the Digitalmars-d-learn
mailing list