Boost logo

Boost :

From: Jason House (jhouse_at_[hidden])
Date: 2003-01-23 14:30:05


I tried to do the following implementation in visual studio 6 to see if
I could get a named pair class.

I tried a number of approaches, but none worked with my compiler. Is my
approach fundamentally flawed?

I think that something like this would be a useful utility to have.
Anyone have any ideas on how to improve the class?

********************************
template <typename _T1, int _Name1, typename _T2, int _Name2>
class named_pair{
  public:
  template <int _Name>
  class var{};
  
  class var<_Name1>{
  public:
    _T1 value;
  }
  
  class var<_Name2>{
    _T2 value;
  }
};

enum{ Cash, Name };

void main(int argc, char *argv[]){
  named_pair<float, Cash, char*, Name> foobar;

  foobar.var<Cash>.value = 32.2;
  foobar.var<Name>.value = "Fred";
}


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