$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] utility class: lazy data type
From: Olaf Peter (ope-devel_at_[hidden])
Date: 2009-01-19 09:19:36
> template<class T>
> class lazy
> {
> public:
> explicit lazy(function<T ()> fetch)
> : _fetch(fetch)
> {
> }
>
> T get()
> {
> if (!_cached)
> _cached = _fetch();
> return _cached.get();
> }
>
> private:
> optional<T> _cached;
> function<T ()> _fetch;
> };
I miss a set function; e.g. from parser you get a string which is
interpreted as a number and used, later changed/rewritten and saved
(e.g. by use of spririt's Qi & Karma) as string again. Maybe another
pattern for this use case is appropriate?
Regards,
Olaf