Вот мой код:
Код: Выделить всё
// Property class
template
class ReadOnlyProperty
{
public:
typedef T (*GetterFunc)();
protected:
GetterFunc GetterFuncField;
public:
ReadOnlyProperty(GetterFunc Getter) : GetterFuncField(Getter) {}
// ReSharper disable once CppNonExplicitConversionOperator
operator const T() const
{
return GetterFuncField();
}
T& Value()
{
return GetterFuncField();
}
T& operator()()
{
return GetterFuncField();
}
const T& operator()() const
{
return GetterFuncField();
}
};
template
class Buffer
{
protected:
T* MinAddrPointer;
T* MaxAddrPointer;
size_t CapacityField;
public:
Buffer(T* StorageArray, const size_t StorageCapacity)
{
MinAddrPointer = StorageArray;
MaxAddrPointer = StorageArray + Capacity - 1;
CapacityField = StorageCapacity;
}
ReadOnlyProperty MinAddr {[this]()-> T* {return this->MinAddrPointer;}};
ReadOnlyProperty MaxAddr {[this]()-> T* {return this->MaxAddrPointer;}};
ReadOnlyProperty Capacity {[this]()-> size_t {return this->CapacityField;}};
};
int main()
{
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/78693283/c-c2665-no-overloaded-function-could-convert-all-the-argument-types[/url]