Boost logo

Boost :

From: Dale E. Strickler (DaleS_at_[hidden])
Date: 2001-12-19 13:39:30


I have been searching through the boots library and have not yet found what
I was looking for so I thought I would post a brief note to see if there is
something in the works of if someone has a reference that might help.

I would like to have variables that act like intrinsic types int and double
but which are type unique in signatures. For instance I would like to do
the following:

some_sort_of_typedef<int> Apples_t;
some_sort_of_typedef<int> Oranges_t;

class cFruitMangager
{
public:
         // ....some constructors and such
         AppleFun(Apples_t a){ // do stuff with apples just like ints.};
         OrangeFun(Oranges_t o){ // do stuff with oranges just like ints. };

         // .. more stuff
}

void main(void)
{
         cFruitMangager MyManager;
         Apple_t aApple;
         Orange_t aOrange;

         MyManager.AppleFun(aApple); // Ok!
         MyManager.AppleFun(aOrange); // Won't compile type
mismatch.

         // also
         Orange_t newOrange=aOrange * 2 // ok!
         newOrange= aOrange + 1.03 // ok BUT does int math.

         Apple_t newApple=aApple + aOrange; // Won't compile type
mismatch.

         newApple=aApple * 2 // ok!
         newApple= aOrange + 1.03 // ok BUT does int math.
}

Any ideas?

Best Regards,

Dale E. Strickler
President and Sr. Consultant
___________________________________
___________________________________
DES Software Engineering Consulting
E-mail: DaleS_at_[hidden]
  Voice: 434-846-7003 (NOTE New area code!)
    FAX: 434-846-7040 (NOTE New area code!)
    Web: www.dessec.com


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