Boost logo

Boost :

Subject: Re: [boost] Nasty compile time reflection and iteration for POD types using C++14 without macro
From: Klemens Morgenstern (klemens.morgenstern_at_[hidden])
Date: 2016-03-25 13:04:03

> I've tired the following:
> #include <boost/current_function.hpp>
> #include <iostream>
> template <class T>
> struct ctti {
> static constexpr const char* n() noexcept {
> }
> };
> int main() {
> constexpr auto c = ctti<int>::n() + 10;
> std::cerr << c;
> }

Ok, might be possible. But you still get problems when passing const
char* as a template parameter which you still would need to do in order
to get the type. I.e. I can't use a null-terminated string, but need an
array of chars and it's size.

> And that worked on GCC5.3 and Clang3.7.
> Looks like it's time to continue the work on
> and make the
> type_index constexpr :)

Ah, then I'll redirect my PR.

> Actually you do not need to add types. The code must work with any POD type
> as member types are either
> 1) fundamental types (that are registered)
> 2) or PODs, then goto step 1) for that member

Oh, I thought you'd need to register POD-Types. What about enumerators?

Boost list run by bdawes at, gregod at, cpdaniel at, john at