od JANIK_ » 26. 12. 2010 22:03
Odstarnit sa to da celkom jednoducho avsak upravou read only zdrojku literal_storage.hpp staci spravit z friend operatora== membra vid. cast upraveneho suboru:
Kód: Vybrat vše
template <typename T, bool ISID>
class cptr_lit_storage {
public:
cptr_lit_storage() : ptr_(0) { }
cptr_lit_storage(const T* ptr) : ptr_(ptr) { }
const T& operator*() const { return *ptr_; }
bool operator!() const { return !ptr_; }
const T* operator->() const { return ptr_; }
private:
const T* ptr_;
// template <typename TT, bool ISIDISID>
// friend bool operator==(const cptr_lit_storage<TT, ISIDISID> &lhs, const cptr_lit_storage<TT, ISIDISID> &rhs);
template <typename TT, bool ISIDISID>
friend bool operator!=(const cptr_lit_storage<TT, ISIDISID> &lhs, const cptr_lit_storage<TT, ISIDISID> &rhs);
template <typename TT, bool ISIDISID>
friend bool operator!=(const TT *lhs, const cptr_lit_storage<TT, ISIDISID> &rhs);
public:
bool operator==(const cptr_lit_storage<T, ISID> &rhs) { return ptr_==rhs.ptr_; }
};
//template <typename T, bool ISID>
//bool operator==(const cptr_lit_storage<T, ISID> &lhs, const cptr_lit_storage<T, ISID> &rhs) { return lhs.ptr_==rhs.ptr_; }
template <typename T, bool ISID>
bool operator!=(const cptr_lit_storage<T, ISID> &lhs, const cptr_lit_storage<T, ISID> &rhs) { return lhs.ptr_!=rhs.ptr_; }
template <typename T, bool ISID>
bool operator!=(const T *lhs, const cptr_lit_storage<T, ISID> &rhs) { return lhs!=rhs.ptr_; }
Odstarnit sa to da celkom jednoducho avsak upravou read only zdrojku literal_storage.hpp staci spravit z friend operatora== membra vid. cast upraveneho suboru:
[code]
template <typename T, bool ISID>
class cptr_lit_storage {
public:
cptr_lit_storage() : ptr_(0) { }
cptr_lit_storage(const T* ptr) : ptr_(ptr) { }
const T& operator*() const { return *ptr_; }
bool operator!() const { return !ptr_; }
const T* operator->() const { return ptr_; }
private:
const T* ptr_;
// template <typename TT, bool ISIDISID>
// friend bool operator==(const cptr_lit_storage<TT, ISIDISID> &lhs, const cptr_lit_storage<TT, ISIDISID> &rhs);
template <typename TT, bool ISIDISID>
friend bool operator!=(const cptr_lit_storage<TT, ISIDISID> &lhs, const cptr_lit_storage<TT, ISIDISID> &rhs);
template <typename TT, bool ISIDISID>
friend bool operator!=(const TT *lhs, const cptr_lit_storage<TT, ISIDISID> &rhs);
public:
bool operator==(const cptr_lit_storage<T, ISID> &rhs) { return ptr_==rhs.ptr_; }
};
//template <typename T, bool ISID>
//bool operator==(const cptr_lit_storage<T, ISID> &lhs, const cptr_lit_storage<T, ISID> &rhs) { return lhs.ptr_==rhs.ptr_; }
template <typename T, bool ISID>
bool operator!=(const cptr_lit_storage<T, ISID> &lhs, const cptr_lit_storage<T, ISID> &rhs) { return lhs.ptr_!=rhs.ptr_; }
template <typename T, bool ISID>
bool operator!=(const T *lhs, const cptr_lit_storage<T, ISID> &rhs) { return lhs!=rhs.ptr_; }
[/code]