It honestly depends how in depth you want to go with reflection, in reality it can be extremely simple, to complex like code generation. Personally, I'd stick with a custom solution instead of using C++17, but that's just me.
This reflection system was started from Insomniac Games and expanded over time :
https://github.com/HeliumProject/Reflect
A little self promotion , this is a small blog about my old reflection system, it's had a major refactor and looks quite literally nothing like this now, but it worked at the time
http://www.ademolathompson.com/archetypesystem/
C++ Reflection is quite a large topic, so there are dozens of papers , blogs, etc about this exact topic if you google it.
A basic C++ implementation could be like this
class CClass
{
typedef CObject*(*ClassConstructorType);
CClass(const char* Name, .... ClassConstructorType Ref):
...
CObject* ConstructInstance() const
{
return (*m_ClassConstructorRef)();
}
private:
// member parameters like size, alignment, etc
uint32 ClassSize;
uint32 ClassAlignment;
ClassConstructorType m_ClassConstructorRef;
std::vector<CProperty*> Properties;
std::vector<CFunction*> Functions;
std::string ClassName;
CClass* m_SuperClass;
};
// base class for all properties (int...float...etc)
class CProperty
{
// functions to construct the value type, destruct the value type, copy, etc
};
// base class for all "reflected types"
class CObject
{
virtual CClass* GetClass() const {};
....
};
// in the header
class CDerivedClass : public CObject
{
DECLARE_CLASS(CDerivedClass,CObject)
};
// in the cpp file
IMPLEMENT_CLASS(CDerivedClass)
#define DECLARE_CLASS(TClassType,TSuperClassType)\
typedef TSuperClassType Super;\
virtual CClass* GetClass() const override { return GetStaticClass(); }
static CClass* GetStaticClass();\
static CObject* _ClassConstructor() { return new TClassType(); }
#define IMPLEMENT_CLASS(TClassType)\
CClass* TClassType:GetStaticClass()\
{
static CClass* ReturnClass = nullptr;
if(ReturnClass==nullptr)
{
ReturnClass = new CClass(#TClassType,sizeof(TClassType),AlignOf(TClassType),#_ClassConstructor);
... add the properties, etc
}
return ReturnClass;
}