--- Log opened Thu Sep 24 00:00:40 2020 |
00:30 | | Kindamoody is now known as Kindamoody[zZz] |
00:56 | | himi [sjjf@Nightstar-1drtbs.anu.edu.au] has joined #code |
00:56 | | mode/#code [+o himi] by ChanServ |
02:03 | | * McMartin sets a small fraction of his soul on fire |
02:04 | | * McMartin has now successfully constructed code that makes use of std::enable_if. |
02:08 | <~Vornicus> | what does that do |
02:09 | <&McMartin> | terrible things |
02:10 | <~Vornicus> | well, yes, I mean, it's C++ |
02:10 | <&McMartin> | The only answer I can put into words right now is "why would you use it", and the answer is "if you have a class defined in terms of another class, and you want certain methods to exist if and only if a compile-time expression is true" |
02:10 | <&McMartin> | There's a suite of other things with names like std::is_default_constructible<T> that are intended to be used in concert with it. |
02:15 | <&McMartin> | What it *does* is end up specifying a type that will or will not compile depending on its template arguments, and then rely on the "Substitution Failure Is Not An Error" property of C++ template expansion to essentially selectively delete definitions from different expansions of the same template. |
02:16 | <&McMartin> | And I've now built up enough understanding of what's going on to actually make it do a thing I intended it to do. |
02:16 | <~Vornicus> | so like -- hang on let me see here |
02:16 | <&McMartin> | This is, like, the dark mirror of finally understanding how call/cc works |
02:17 | <&McMartin> | Also, "subsitution failure is not an error" is usually abbreviated SFINAE |
02:17 | <&McMartin> | https://pbs.twimg.com/media/EeqLiY3XkAA4aK3?format=jpg&name=small |
02:20 | <~Vornicus> | okay: I reimplement glsl's basic types, which include a variety of vector types that vary based on the stored type - vec3 is 3 floats, ivec2 is 2 integers, bvec4 is 4 booleans. Most operators exist but are restricted to the vector types whose underlying scalar type they would normally work on; I could use enable_if to specify ivec and vec both as subclasses of this big nasty template and then ivec will have the bit operators enabled |
02:21 | <~Vornicus> | which I do grant sounds like a terrible idea |
02:23 | <~Vornicus> | or alternatively I could do something with it to come up with the swizzles based on the dimensionality of the thing or something |
02:25 | <&McMartin> | You don't need to mess with template metaprogramming for the latter |
02:26 | <&McMartin> | You can hand-override specific types, so if the dimensionality were part of the type (as a template argument Vec<int, 4> or whatever) then you could write specific implementations for various values of that integer. |
02:26 | <&McMartin> | Or! |
02:26 | <&McMartin> | You could just define individual functions for this like a human being from the planet Earth. |
02:27 | <&McMartin> | Now, the thing I was doing in *this* case involved selectively making a default constructor appear, which turns out to be more difficult than most usages of it |
02:28 | <&McMartin> | But the real thing I was doing was "wrapping one of the fields", and so what I *really* want to do is just say "whatever you're wrapping, take any constructor arguments it does and pass it on to them" |
02:28 | <&McMartin> | C++11 added approximately a vigintillion corner cases to this, and there are some spells you can use to manage it, but I haven't mastered them yet. |
02:29 | <&McMartin> | But that means the solution involves the use of variadic templates and then also a thing that isn't actually a thing the compiler knows exists, but when reasoning about the compiler, is called a "universal reference" or "forwarding" reference. |
02:29 | <&McMartin> | As a special case of the thing that the compiler *does* know about, which are "rvalue references" |
02:30 | <&McMartin> | Which the compiler uses to distinguish copy from move operations |
02:30 | <&McMartin> | ... and this is why you want to use Rust instead if you actually care about this nonsense, but I seek forbidden knowledge this week, I guess |
02:37 | <~Vornicus> | that's a lot of fucking corner cases |
02:38 | <&McMartin> | I'm using one of the standard companion works regarding "stuff that was added to C++ in 2011" |
02:39 | <&McMartin> | Two chapters summing up to a hundred pages cover "so, you're going to have to actually understand how template expansion interoperates with other things, and what types ultimately end up actually getting deduced" |
02:40 | <&McMartin> | This for a feature whose ideal endpoint is supposed to be "this is invisible outside of the standard library, but we're exposing it so you can do similar things" |
02:45 | <&McMartin> | Now that I dig into it though, it turns out that the thing I want is a thing that is poorly specified because it ends up usurping the copy operations that the compiler does under the hood while passing arguments to functions and such |
02:46 | <&McMartin> | Good times |
02:46 | <&McMartin> | Well, that's an even better reason to burn down this whole concept. |
02:49 | <~Vornicus> | cute |
02:52 | <&McMartin> | https://pastebin.com/8wphZgt1 |
03:22 | | Vornicus [Vorn@ServerAdministrator.Nightstar.Net] has quit [Connection closed] |
03:57 | | Degi [Degi@Nightstar-gj2gaa.dyn.telefonica.de] has quit [Operation timed out] |
04:10 | | Degi [Degi@Nightstar-10huln.pool.telefonica.de] has joined #code |
05:35 | | catalyst_ [catalyst@Nightstar-st2ljl.dab.02.net] has joined #code |
05:38 | | catalyst [catalyst@Nightstar-jfgoib.dab.02.net] has quit [Ping timeout: 121 seconds] |
05:48 | | VirusJTG [VirusJTG@Nightstar-42s.jso.104.208.IP] has quit [Connection closed] |
05:48 | | VirusJTG [VirusJTG@Nightstar-42s.jso.104.208.IP] has joined #code |
05:48 | | mode/#code [+ao VirusJTG VirusJTG] by ChanServ |
06:06 | | celticminstrel [celticminst@Nightstar-8kptuo.dsl.bell.ca] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!] |
06:11 | | gnolam_ is now known as gnolam |
06:11 | | mode/#code [+o gnolam] by ChanServ |
06:36 | | Vorntastic [uid293981@Nightstar-ks9.9ff.184.192.IP] has joined #code |
06:36 | | mode/#code [+qo Vorntastic Vorntastic] by ChanServ |
07:12 | | himi [sjjf@Nightstar-1drtbs.anu.edu.au] has quit [Ping timeout: 121 seconds] |
08:13 | | Kindamoody[zZz] is now known as Kindamoody|afk |
09:27 | | himi [sjjf@Nightstar-v37cpe.internode.on.net] has joined #code |
09:27 | | mode/#code [+o himi] by ChanServ |
09:40 | | Emmy [Emmy@Nightstar-l49opt.fixed.kpn.net] has joined #code |
10:21 | | pinkmobile [uid208117@Nightstar-h2b233.irccloud.com] has quit [[NS] Quit: Connection closed for inactivity] |
11:01 | | Reiv [NSkiwiirc@Nightstar-ih0uis.global-gateway.net.nz] has quit [[NS] Quit: http://www.kiwiirc.com/ - A hand crafted IRC client] |
11:25 | | JustBob [justbob@Nightstar.Customer.Dissatisfaction.Administrator] has quit [[NS] Quit: ] |
12:06 | | catalyst [catalyst@Nightstar-sktdeb.dab.02.net] has joined #code |
12:07 | | catalyst_ [catalyst@Nightstar-st2ljl.dab.02.net] has quit [Ping timeout: 121 seconds] |
13:09 | | catalyst [catalyst@Nightstar-sktdeb.dab.02.net] has quit [[NS] Quit: -a- Connection Timed Out] |
13:09 | | catalyst [catalyst@Nightstar-sktdeb.dab.02.net] has joined #code |
15:09 | | Vornicus [Vorn@ServerAdministrator.Nightstar.Net] has joined #code |
15:09 | | mode/#code [+qo Vornicus Vornicus] by ChanServ |
16:29 | | pinkmobile [uid208117@Nightstar-h2b233.irccloud.com] has joined #code |
17:05 | | Vorntastic [uid293981@Nightstar-ks9.9ff.184.192.IP] has quit [[NS] Quit: Connection closed for inactivity] |
17:12 | | celticminstrel [celticminst@Nightstar-8kptuo.dsl.bell.ca] has joined #code |
17:12 | | mode/#code [+o celticminstrel] by ChanServ |
18:35 | | catalyst_ [catalyst@Nightstar-f5rf9b.dab.02.net] has joined #code |
18:37 | | catalyst [catalyst@Nightstar-sktdeb.dab.02.net] has quit [Ping timeout: 121 seconds] |
18:41 | | Kindamoody|afk is now known as Kindamoody |
22:49 | | himi [sjjf@Nightstar-v37cpe.internode.on.net] has quit [Ping timeout: 121 seconds] |
23:40 | | Emmy [Emmy@Nightstar-l49opt.fixed.kpn.net] has quit [Ping timeout: 121 seconds] |
--- Log closed Fri Sep 25 00:00:41 2020 |