typestring icon indicating copy to clipboard operation
typestring copied to clipboard

Maby a nicer Front-Page Example

Open ajneu opened this issue 7 years ago • 0 comments

Thanks for this great class!! (It took me a while to realize that it does exactly what I wanted!)

Please consider putting an example like this on the front-page:

#include "typestring.hh"

// wrapper to give any class T a fixed static name
template <typename T, typename NAME>
class MyClass : public T
{
public:
    
    using T::T;

    constexpr static const char *get_name() { return NAME::data(); }
};



#include <vector>
#include <iostream>

int main()
{
    MyClass<std::vector<int>, typestring_is("vec0")> vec0{0, 2, 4};
    MyClass<std::vector<int>, typestring_is("vec1")> vec1{1, 3, 5};
    auto &container = vec0;

    std::cout << container.get_name() << std::endl; // prints vec0
}

And consider mentioning typestring over here

;)

ajneu avatar Jul 02 '17 20:07 ajneu