Boost logo

Boost :

From: Dory Zidon (doryzpost_at_[hidden])
Date: 2002-04-03 18:10:09


Hello people of the boost libs...
Many times we need a customized special chache for a
special solution, but many time just a simple cache
can do the trick. For those situations I wrote a
generic_cache. Like all stl containers it is generic
for all types and saves a defined amount of latest
objects.
  I was wondering if other people would like to use it
and perhaps add it to boost lib.
  Thanks.
Usage:
pragma warning(disable:4786)
#include "object_cache.h"
#include <iostream>

class Int
{
public:
    Int(int m = 0) : _m(m) {};
    
    ~Int() {};
    int getm() const {return _m;};
protected:
    int _m;
};

int main(int argc, char* argv[])
{

    object_cache<int,Int> myCache;

    Int i1(5), i2(7) , i3(11);
    myCache[1] = i1;
    myCache[2] = i2;
    myCache[3] = i3;

    Int i4 = myCache[1];

    cout << i4.getm();

   return 0;
}

   Dory.

http://www.sold.com.au - SOLD.com.au Auctions
- 1,000s of Bargains!


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