[{"data":1,"prerenderedAt":211},["ShallowReactive",2],{"project-32236447":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":21,"format":22,"keywords":23,"reception":28,"sentiment":29,"stance_mix":30,"scored_comments":35,"aspects":36,"strip":40,"post_text":42,"what":43,"said":58,"maker_in_thread":108,"shape":116,"grid":120,"attempts":172,"same_week":173,"maker_shows":31,"maker_hidden":203,"reader_version":204,"card":205},"32236447","libvital","The Ultimate C++14 (and later) Enum Library","title","Show HN: The Ultimate C++14 (and later) Enum Library","https:\u002F\u002Fgithub.com\u002Fmehrdadn\u002Flibvital\u002Fblob\u002Fmaster\u002Fdoc\u002Fcpp\u002Fvital\u002Fcore\u002Fenum.md","github.com","mehrdadn",1658831083,2022,38,20,1125,2570,44,"shown","languages","c++ enum library","library",[24,25,26,27],"c++ enum","enum to string","c++14","enum reflection","curious",0.051,{"positive":31,"neutral":32,"mixed":33,"critical":34},2,3,0,1,6,{"docs":37,"design":38,"idea":39},{"positive":34,"critical":34},{"positive":33,"critical":33},{"positive":34,"critical":33},[34,33,41,32,33,32,32,33,41,33,33,33,33,33,33,33,33,33,33,33],5,null,{"problem":44,"audience":42,"pricing":42,"motivation":42,"time_to_build":42,"stack":51,"openness":56,"stage":57,"team_size":57},{"value":45,"source":46,"evidence":47},"C++ has no built-in facilities for enums, so people hand-write brittle enum-specific code","maker",[48],{"id":49,"by":11,"text":50},"32248593","Ah sorry about that, thanks for the feedback! I can try to answer these here (and hopefully update the documentation as well when I get the chance): - The problem is basically…",[52],{"value":53,"source":46,"evidence":54},"C++14",[55],{"id":49,"by":11,"text":50},"open_source","unknown",{"praise":59,"objections":68,"requests":76,"questions":84,"alternatives":92},[60],{"value":61,"source":62,"evidence":63},"Ambitious feature set; wanted enum-to-string support","commenter",[64],{"id":65,"by":66,"text":67},"32248526","shultays","It is amazing how much effort is going to simplify adding \"enum_to_string(e)\" support in C++ or C. What is the reason this not being part of C++ standard?",[69],{"value":70,"source":62,"evidence":71},"Documentation does not explain the problem or compare alternatives",[72],{"id":73,"by":74,"text":75},"32248493","rsp1984","This is probably an amazing library, yet the documentation gives me no clue * what the problem is that needs solving, * how the lib solves it and how that's preferable over…",[77],{"value":78,"source":62,"evidence":79},"Range-based iteration over enum values",[80],{"id":81,"by":82,"text":83},"32249991","Koshkin","One other thing that have felt the need to solve was iteration through the values as if it was a container, i.e. using the range-based for loop.",[85],{"value":86,"source":62,"evidence":87},"How does it compare to magic_enum",[88],{"id":89,"by":90,"text":91},"32248121","soylentgraham","Any chance anyone knows how this compares to magic_enum (which iirc is c++17+ only? Though c++17 seems to be supported every platform i work on now) No string -> enum would…",[93,100,104],{"value":94,"source":62,"evidence":95},"magic_enum",[96,97],{"id":89,"by":90,"text":91},{"id":98,"by":11,"text":99},"32248362","To my knowledge magic_enum has some severe limitations; for example, it limits the range of enum values, it cannot handle duplicate enum values, it uses compiler-specific hackes,…",{"value":101,"source":46,"evidence":102},"wise_enum",[103],{"id":98,"by":11,"text":99},{"value":105,"source":46,"evidence":106},"meta_enum",[107],{"id":49,"by":11,"text":50},{"comments":109,"answered":31,"key":110},4,[111,112,115],{"id":49,"text":50},{"id":113,"text":114},"32254370","That's supported here! You can do: ``` for (auto const &member : enum_traits\u003CE>::members()) { std::cout \u003C\u003C member.name() \u003C\u003C std::endl; } ```",{"id":98,"text":99},{"commenters":117,"max_depth":35,"maker_replies":109,"first_comment_mins":118,"lifespan_hours":119},11,1323,50,[121,123,125,128,130,132,135,137,139,140,143,147,151,154,157,160,163,165,167,169],[73,33,34,122,74,33],"project\u002Fcritical\u002Fdocs",[49,33,33,124,11,34],"maker\u002Fneutral\u002Fdocs",[126,33,41,127,74,33],"32248844","maker\u002Fpositive\u002Fdocs",[81,33,32,129,82,33],"project\u002Fneutral\u002Fdesign",[113,33,33,131,11,34],"maker\u002Fneutral\u002Fdesign",[133,33,32,134,66,33],"32248606","project\u002Fneutral\u002Fdocs",[89,34,32,136,90,33],"project\u002Fneutral\u002Fnone",[98,34,33,138,11,34],"project\u002Fpositive\u002Fidea",[65,31,41,138,66,33],[141,31,33,142,11,34],"32248643","project\u002Fneutral\u002Fidea",[144,31,33,145,146,33],"32248743","other\u002Fneutral\u002Fidea","gpderetta",[148,31,33,149,150,33],"32250145","other\u002Fneutral\u002Fnone","tialaramex",[152,31,33,153,146,33],"32256432","commenter\u002Fneutral\u002Fnone",[155,31,33,149,156,33],"32250160","pjmlp",[158,31,33,145,159,33],"32249472","DrBazza",[161,31,33,149,162,33],"32250164","bluGill",[164,31,33,149,159,33],"32251836",[166,31,33,149,66,33],"32263123",[168,31,33,149,162,33],"32263609",[170,32,33,149,171,33],"32250209","fitch321",[],[174,179,184,189,194,199],{"id":175,"name":176,"points":177,"category":178},"32216436","Hexapipes",537,"games",{"id":180,"name":181,"points":182,"category":183},"32212235","Kvass",227,"dev_tools",{"id":185,"name":186,"points":187,"category":188},"32179856","Pg_jsonschema",203,"data",{"id":190,"name":191,"points":192,"category":193},"32240511","Blueboat",123,"infrastructure",{"id":195,"name":196,"points":197,"category":198},"32229278","Plunk",109,"web_saas",{"id":200,"name":201,"points":202,"category":198},"32249392","Birdy",89,false,"v2",{"id":206,"name":5,"line":6,"ai":203,"cat":20,"year":13,"points":14,"comments":15,"rec":28,"s":207,"top":18,"kw":208,"maker":11,"domain":10,"tier":19,"attempts":33,"strip":209,"url":9,"mix":210,"praise":61,"objection":70,"sub":21},32236447,0.05,[24,25,26,27],"10530330500000000000",[31,32,33,34],1794036622978]