felixguendling / cista

Cista is a simple, high-performance, zero-copy C++ serialization & reflection library.
https://cista.rocks
MIT License
1.78k stars 113 forks source link

WIP: implement static type hashing #153

Closed AdelKS closed 1 year ago

AdelKS commented 1 year ago

Starting from the issue #152 that I opened, this is an initial work towards that goal, I hope you find this as a nice addition. (this change unfortunately did not fix my issue, which is elsewhere it seems).

I implemented a second path when hashing, when the classes that are getting hashed have a static member function called hash_t static_type_hash(hash_t h). Then, the same approach as before is used: the user has to manually call the same function on its members to obtain the final hash.

I have a little issue where the struct has_static_hash isn't working as I hoped it would. Needs investigating.

Adel.

AdelKS commented 1 year ago

Also, the class cista::array seems to have an implementation that is rather redundant with std::array: I do not see any cista-specific quirks implemented inside. From the looks of it std::array can be directly used. Or at most a definition like this

namespace cista {

template <class T, size_t N>
class array: public std::array<T, N> {
public:
  using std::array<T, N>::array;
};

}
AdelKS commented 1 year ago

It appears that this addition is not welcome, I will close this PR for now.