| 158 | |
| 159 | // The type used to store a single cached item. |
| 160 | struct CacheEntry |
| 161 | { |
| 162 | CacheEntry(); |
| 163 | |
| 164 | // We use a boost::variant to compactly store |
| 165 | // a union of the data needed for each Status. |
| 166 | // |
| 167 | // - Uncached : A boost::blank instance |
| 168 | // - Cached : The Value itself |
| 169 | // - Failed ; The exception thrown by the GetterFn |
| 170 | typedef boost::variant<boost::blank, Value, std::exception_ptr> State; |
| 171 | |
| 172 | State state; |
| 173 | Cost cost; // the cost for this item |
| 174 | |
| 175 | Status status() const; |
| 176 | |
| 177 | }; |
| 178 | |
| 179 | // Policy. This is responsible for |
| 180 | // the internal storage for the cache. |