C++ Template: Table Class
Derek Burdick
derek at burdick.cc
Wed Mar 16 23:40:19 MST 2005
David Smith wrote:
>I'm looking for a template class that'll let me setup aribtrarily wide
>tables. Something like this:
>
> std::table< int, int, float, int > myTable;
> ...
> iter = myTable.find( int, int, float );
>
>Or something like that. The goal is to setup some lookup tables and reuse
>the same code for each one, even though they have different numbers of
>columns and different typed columns. It needs to be self-contained in the
>code, so something like SQLite is out. Any ideas?
>
>--Dave
>.===================================.
>| This has been a P.L.U.G. mailing. |
>| Don't Fear the Penguin. |
>| IRC: #utah at irc.freenode.net |
>`==================================='
>
>
I would look at tuples for the variable part.
http://www.boost.org/libs/tuple/doc/tuple_users_guide.html
As far as having it in a table, you could try to use a vector and write
your own compare function. That way you could have:
std::vector<tuple<int, int, float, int>, compare class > ... My syntax
is most likely off, but you get the idea.
It as been a while since I have done any hardcore template programming
,but maybe this will help start you down the right path.
Derek
More information about the PLUG
mailing list