« first day (1805 days earlier)      last day (3146 days later) » 

11:03 PM
@StackedCrooked At work we do this enough that we've written a bit of Python to parse an input in a fairly simple format, and generate appropriate source code.
 
@sehe My approach is usually involves recording first "case" and then repeat the macro.
@JerryCoffin Cool.
It would be nice if demangler could be used for enumerators.
 
@JerryCoffin I wouldnt be surprised if most companies of reasonable size had some kind of automated solution. This kind of boilerplate is just so tedious to write by hand yet generally not so hard to automate.
 
The most ambitious thing I've done with macros is introducing namespaces to an existing project that did not have namespaces.
 
@Borgleader Probably. It is really annoying that it hasn't been handled in the language spec yet (yeah, I know--if I want it badly enough, I'm welcome to write up a proposal).
 
And it's also annoying that we haven't been able to come up with a clever library/macro/language trick that enables us to do it.
 
11:11 PM
@JerryCoffin Indeed, I'm surprised it hasnt.
(yeah I know, I'm welcome to write my own language)
 
no you're not
 
@Borgleader Hm. Not sure about that.
 
Xeo
@StackedCrooked enable what?
 
@sehe :(
 
@StackedCrooked yeah, I've never been tempted to generate it
 
11:12 PM
@Xeo Something that automates writing a enum-to-string routine.
 
Xeo
hm. closest would be X-macros
 
Yeah. But x-macros are too big of a setup for a such small routine.
But yeah, I suppose they are the best thing.
 
Xeo
look fugly, though
 
@StackedCrooked I guess what annoys me is that it actually is possible to automate it to some degree (if you want to badly enough) but the cure is almost always worse than the disease, so to speak.
 
Exactly.
All attempts end up being overkill.
 
Xeo
11:14 PM
unreal does it "for free"
but then again, it generates their own metadata stuff for interactions with blueprints too
 
Just hoverin' and stuff.
 
@StackedCrooked Precisely--at the same time, it's something that arises so often, it's clearly worth a real fix. In fact, I'm pretty sure it's single most common thing people want from reflection in C++ (second would probably be auto-generating I/O functions for POD-ish structs).
 
One nice thing with enums is that nowadays the compiler will warn if your switch is missing an enumerator. So if you add an enumerator then you won't forget to update the to_string routine.
 
enums are great
 
Xeo
I usually do a c-style array mapping from enumerator to string (only works for linearly increasing enums, of course)
static char const* names[to_underlying(teh_enum::count)] = { "...", "...", ... };-style
 
11:18 PM
I've used that in the past.
Dunno why I switched to switches.
I suppose the independence from enumerator increment.
And the ability to easily write it using vim macros
 
@StackedCrooked They do work for sparse values, but that's about the only advantage I see. I usually use an array of strings too.
 
Xeo
neither works properly with aliasing enumerators, though
i.e., multiple enumerators with the same value
 
@Xeo "Doctor it hurts when I ..."
 
Xeo
:D
a few of the enums I'm creating for our game look something like enum class blah : uint8 { a, b, c, count, first = a };, to enable relatively easy iteration (with some one-time boilerplate for an operator++)
 
Could you explain how this is related to generating sin-tables [sic]? — sehe 12 secs ago
uhuh
 
11:22 PM
OpenGL is really noisy sometimes.
 
@ElimGarak is that a passenger jet blurred right behind the cockpit? And what is the sharp fragment sticking out on top?
 
@sehe Yeah, I like to shoot them down. That's the air intake for vertical mode
 
I think operator++ could be generically implemented with std::is_enum and std::underlying_type.
As long as increment is always 1.
 
Xeo
@StackedCrooked that's the one-time boilerplate
 
Yes.
 
11:24 PM
Hah.
 
@ElimGarak ah
 
wheels does the same thing.
 
Xeo
I got a smaller version of it for our game
 
Only problem with this approach is that the operators for this are not available in the namespace of the type.
 
Xeo
just the necessary stuff
 
11:25 PM
So if you want to e.g. OR values in a constructor default value list... you just kinda can't.
Which, IMHO, is a TERRIBLE usability flaw.
 
Xeo
yeah, needs using namespace utility::operators; before usage for my version too
I got another version that doesn't need that, but needs a hint that the global operators should apply to a type
 
@ThePhD You obviously just need to put everything in the global namespace. Nobody really needs this other stuff.
 
Mine requires both the hint and the using.
 
If the operators on your type are defined in a diffferent namespace than your type then you're gonna have a hard time.
 
@ThePhD not being able to correctly cause ADL in a constructor list irks me many times
 
11:28 PM
I feel like getting back into FSX.
 
@ElimGarak that looks old
 
Xeo
1 min ago, by Xeo
I got another version that doesn't need that, but needs a hint that the global operators should apply to a type
 
I've been considering just wrapping all my types up with this class, at least in the case of constructor stuff. Then I could just do it anywhere and not give a damn.
 
Xeo
it's not too bad, really
a single added line after the enum definition
 
@sehe Yup, came out in 2006.
 
11:29 PM
@AndyProwl you going to the dinner? I wonder how many people will amass for that :D
 
@Xeo how does it work?
 
hehe. Not what I meant with old
 
Xeo
lemme see if I can whip it up again
 
Ah, the plane? That's the A320, it is kinda old. Not terribly though.
 
@Griwes what dinner?
 
11:30 PM
@AndyProwl the random amassment of people going no-one yet knows where at 6pm at Hyatt? :D
 
Wat? Where did you get this info?
Is it on the website?
Also are you going?
 
No, just randomly passed around between people ;p I am half-sure I heard someone mention it in a group of people you were standing with after the panel, though I might be wrong.
Yeah, I'm going to go.
 
Hyatt at 6?
 
Pretty impressive for a decade old sim
 
11:32 PM
Yes - Hyatt lobby at 6pm.
 
@Griwes is it an invitation thing? I haven't talked to anyone but I'd like to join
Well I guess I'll find out at the lobby. We'll meet there and see
 
I'm pretty sure it isn't. :P
 
Ok cool
 
Is cppcon a fun place?
 
I'm going for a swim now but I'll be done by that time
 
11:34 PM
@StackedCrooked Yes, although C++Now is better at that.
 
That's former boostcon, right?
 
Most times I had an interesting discussion this year was with other C++Now attendees.
Yeah.
 
Xeo
@StackedCrooked Hm, I thought I already wrote an example snippet before. Guess not. Gimme a minute.
 
@StackedCrooked Yes.
 
@Griwes The boostcon talks are often most fun to watch as well.
 
11:36 PM
That's probably due to the more homely atmosphere there.
 
@StackedCrooked It's better to go there though.
Hmm...I wonder if I can talk work into sending me next spring...
 
@Griwes Yeah.
 
@JerryCoffin Do it! :D
 
I'm sure they wouldn't see anything funny about the guy from Colorado wanting to get a free trip to Aspen...
 
hah
 
11:40 PM
Then again, if things work out the say they're supposed to, by next spring I might be able to give a presentation... I have very low confidence in that happening though.
 
Xeo
@StackedCrooked Guess this should suffice as a demonstration.
 
@Xeo Declared but undefined functions... va_args...
... So dirty.
 
is_arithmetic_enum(std::declval<E>()) // ADL trigger?
Cool.
 
Xeo
ye
 
Hm, not really adl it seems..?
 
Xeo
11:44 PM
why not?
@ThePhD Better?
(link-fix fixed)
 
I think you un-fixed the link.
 
@ThePhD Not particularly dirty--pretty common for situations like this. It's just for error cases--a worst-match function that'll take a single parameter of any type.
 
Xeo
apparently I did, lol
 
Ah, just not used to seeing ADL enabled by enable_if's params.
 
Pat pat. There, there. Xeo's tired.
 
11:45 PM
Didn't know that was possible.
 
@JerryCoffin I know but.... Undefined functiona dajwhdwajhdfhfawf
It makes me squirm inside.
 
Xeo
@StackedCrooked it's a simple template parameter
@ThePhD Fix fixed!
@ThePhD unevaluated contexts and undefined functions are very close buddies
 
Oh, the ADL is used to enable the constraint, not for the lookup of operator++ itself..?
 
Xeo
ye
the operator is in global namespace
so the constraint is to not have it picked up for every enum ever
 
However, name lookup will stop if operator++ is encountered before reaching global namespace.
 
Xeo
11:49 PM
ah, there was something like that, wasn't there?
can't quite remember, and can't quite say I care too much - it's just an alternative way to provide the operators
 
If a name is found in the current namespace then it will no longer search parent namespaces and start overload resolution.
 
Xeo
mh
 
Basic rule is simple.
ADL is special though.
 
Wow
I finished it.
... Huh, I can close that issue.
Now I need to make texture_2d, texture_1d and render_buffer_2d work...
The last one would require me to understand Framebuffer objects.
And I don't feel like doing that. :<
 
Anyway typedefs are lame.
Not sure if name lookup is any different for alias templates.
According to Stroustrup defining owner<T> as a type alias is sufficient to enable static analysis. But I wonder how that will work. This "tag" will be no longer visible in compiled code, is it?
I mean type aliasing does not affect symbol names / object code does it?
 
11:59 PM
@StackedCrooked He's talking about static analysis of source code (I'm pretty sure). Something lint-like.
 
Ah, I see.
 
That seems unrelated to me. After all, there is no function (like sin) to call to get the name of an enum member as a string. So you couldn't "need to do a for-loop for that" in the first place. — sehe 39 secs ago
Time to place your bets there
 

« first day (1805 days earlier)      last day (3146 days later) »