You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
1.1 KiB
73 lines
1.1 KiB
#include <map>
|
|
#include <pEp/pEpLog.hh>
|
|
#include "pEp/inspect.hh"
|
|
#include "../examples/libc99/libc99.h"
|
|
#include "../src/libc99.hh"
|
|
//#include "../src/POTS.hh"
|
|
|
|
using namespace pEp;
|
|
|
|
struct Struct {
|
|
int a;
|
|
int b;
|
|
};
|
|
|
|
template<typename T>
|
|
class Field {
|
|
public:
|
|
Field() = default;
|
|
Field(T* target) {
|
|
bind(target);
|
|
}
|
|
|
|
void bind(T* target) {
|
|
_target = target;
|
|
}
|
|
operator T()
|
|
{
|
|
return *_target;
|
|
}
|
|
|
|
Field& operator=(T val)
|
|
{
|
|
*_target = val;
|
|
return *this;
|
|
}
|
|
|
|
private:
|
|
T* _target{ nullptr};
|
|
};
|
|
|
|
class A : public Field<A> {
|
|
public:
|
|
A() : _obj{ std::make_shared<Struct>() } {
|
|
a.bind(&_obj->a);
|
|
b.bind(&_obj->b);
|
|
}
|
|
|
|
|
|
std::shared_ptr<Struct> _obj;
|
|
Field<int> a{};
|
|
Field<int> b{};
|
|
};
|
|
|
|
int main()
|
|
{
|
|
Adapter::pEpLog::set_enabled(true);
|
|
pEpLog("start");
|
|
A b{};
|
|
pEpLog(b.a);
|
|
// pEpLog(b.b);
|
|
|
|
{
|
|
A a{};
|
|
a.a = 23;
|
|
a.b = 42;
|
|
pEpLog(a.a);
|
|
// pEpLog(a.b);
|
|
|
|
b = a;
|
|
}
|
|
pEpLog(b.a);
|
|
// pEpLog(b.b);
|
|
}
|
|
|