更完
This commit is contained in:
@@ -131,6 +131,9 @@ struct Pure_Read_Only_Device : Property_Object<Pure_Read_Only_Device> {
|
||||
int id{21};
|
||||
int version{4};
|
||||
};
|
||||
struct Callable_Device {
|
||||
int value{4};
|
||||
};
|
||||
template <>
|
||||
struct structive::Type_Descriptor<Pure_Read_Only_Device> {
|
||||
static auto get() {
|
||||
@@ -184,6 +187,14 @@ static void runtime_read_int(void* context, std::size_t, std::string_view, const
|
||||
*static_cast<int*>(context) = *static_cast<const int*>(value);
|
||||
}
|
||||
int main() {
|
||||
auto callable_accessor = trusted_callable_accessor<Callable_Device>(
|
||||
[](const Callable_Device& value) { return value.value; },
|
||||
[](Callable_Device& target, int value) { target.value = value; });
|
||||
static_assert(Property_Accessor<decltype(callable_accessor)>);
|
||||
Callable_Device callable_device;
|
||||
REQUIRE(callable_accessor.read(callable_device) == 4);
|
||||
callable_accessor.write(callable_device, 9);
|
||||
REQUIRE(callable_device.value == 9);
|
||||
static_assert(Property_Described_Object<Device>);
|
||||
static_assert(!Can_Write_Immutable<Device>);
|
||||
static_assert(!Can_Write_Immutable_By_Key<Device>);
|
||||
|
||||
Reference in New Issue
Block a user