xparq / enumfactory Goto Github PK
View Code? Open in Web Editor NEWSuperfrugal stringified enums in ~50 lines
Superfrugal stringified enums in ~50 lines
Based on: https://stackoverflow.com/a/202511/1479945 (by @Suma) This one compiles on a piece of wood (unlike e.g. the finicky magic_enum.hpp), it's just plain C. And requires basically nothing (unlike e.g. Debdatta Basu's stringizer, that can't even do more than that). Nice. (Examples test-compiled cleanly with c++11, c++17.) Changes to the original: - Added the missing string.h. - Renamed getname to be consistent with its pair. - Eliminated the use of DEFINE_ENUM in the cpps. - Eliminated DECLARE_ENUM altogether. - Reversed the arg order of DEFINE_ENUM to be more natural when calling the X macro sg. like <my enumtype>_DEF. - But I don't like it better this way after all. :) - Added include guards. - Also applied pmttavara's great suggestion: https://stackoverflow.com/questions/147267/easy-way-to-use-variables-of-enum-types-as-string-in-c/202511#comment83003525_202511 - So, no more "which arg order" dilemma! :) - Refactored to be more self-describing. TODO: - Use __VA_OPT__ now to eliminate those ugly trailing commas. - Test/add enum class support. - Test/add enum-in-a-class support. -> Can't do either implicitly. Would require shifting to C++; either -> enumfactory.hpp, or enumfactory++.h
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.