$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2006-07-10 11:57:20
Hello all,
I have one issue, which I would like to discuss here.
In my current project is a need to implement an optional type, this type is considered to be lazy.
I am wondering why C++ or Boost do not offer this possibility.
These are just some thoughts which are really not perfect, but an opinion and interest would be
highly appreciated:
template<class Type, class Allocator /*some other policies like threading etc.*/>
class lazy_type
{
        public:
                //constructors must be considered which
                //should it be possible to copy this type etc.
                //destuctor, must be considered how the object should be deallocated in regards of owning and
non-owning policies
                operator bool()const
                {
                        return ptr_!=NULL;
                }
                Type* operator->()
                {
                        if(!ptr_)
                        {
                                //allocate ptr_ and instantiate it using an allocator or another policy type
                                ...
                        }
                        return ptr_;
                }
        private:
                Type*			ptr_;
};
This type can be a mix of reference counted ptr (shared_ptr) and allocator on request. All
comments  and thoughts are HIGHLY appreciated.
With Kind Regards,
Ovanes Markarian