Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Slurps Mad Rips
Jan 25, 2009

Bwaltow!

eschaton posted:

truly truly truly outrageous

Adbot
ADBOT LOVES YOU

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

gonadic io posted:

ty for this. is there an equivalent in c++ or is it just a bunch of types that are like "lol i've got an internal pointer to myself and you moved me time for ub"

short answer: no

long answer: moves in c++ aren't destructive, so moving an object into another one requires the moved-from object be in a "valid but unspecified state". This typically means that the object will be in its default constructed state (e.g., std::unique_ptr and friends), but for small builtin types that aren't used to modify state in the destructor it's cheaper and faster to not move them or reset their value. If performing an operation on an object would cause UB (for instance, dereferencing a std::unique_ptr), that operation is not protected against, but is antithetical to the idea that you're working with a different object, as the original one was moved elsewhere.

as for rvalue references in general, they're basically a special tag in the type system. I can technically move a value into a function that is then moved into a function (repeat several times) but as long as I don't move said rvalue reference into another object (either via construction or return), its lifetime is unaffected and its scope doesn't change. That said, when an rvalue reference is moved into a function, you need to then explicitly move it once more as it has become an xvalue which has the lvalue property of identity (its named or how else would you interact with it), but also has the prvalue property of safely moving from.

basically this isn't a property of c++, though there are some that wish we could have destructive moves, but that would break a shitload of code as existing code would for the most part continue to compile correctly, but destructors would be secretly reordered and that could cause a huge headache for people that depend on our existing operations. That said, there's a concept being put forth now of relocation which will be the closest thing c++ might get to destructive moves

Also just nipping this in the bud, but c++ value categories are kind of a mess to understand in full legalese so i might have gotten the specifics of lvalue vs glvalue wrong for the second paragraph

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

Luigi Thirty posted:

typedef std::vector<Window *>::iterator WindowIterator;

Now I remember why nobody likes C++.

I'm having flashbacks to 2013 when I was in gamedev and working 100+ hours a week with gcc 4.2 because the toolchain we were targeting didn't support clang.

eschaton posted:

lol at Stepanov's terrible library design, having everything take begin and end iterators instead of having sensible collection protocols

oh but then someone might try to treat collections as interchangeable even though they have different performance characteristics and we can't possibly allow that

Don't forget output iterators with no known end, because having them act as streams with a concept of exhaustion might be bad or something.

iterators as cursors vs iterators as streams was such a colossal fuckup for c++

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

TheFluff posted:

this miserable pile of angle brackets and colons allegedly wraps a c function that uses setjmp/longjmp for error handling (lol libjpeg) such that it throws c++ exceptions instead and im not sure if it’s terrible or awesome

maybe “awful” in the olde English sense is the word I’m looking for

This is actually pretty neat. setjmp/longjmp error handling in stuff like lua means you need to compile these C libraries as C++ just so destructors run and that's a nightmare. That said, this code is deffo c++11/c++14. result_of_t was deprecated in c++17 and removed for c++20.

A more "modern" code example would look like this. i probably hosed up the perfect forwarding for returning a value but who cares you get the idea

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

prisoner of waffles posted:

I understand what it is supposed to do (turning C-style "exception handling" into C++-style)

I read 50 lines and I think I understand them

but now my brain wants to turn off

e: gently caress me now I'm reading jumpman.cpp

tbqh the idea of converting setjmp/longjmp to a c++ exception entirely within c++ without using ABI specific info is an insane idea and I never would have thought it was possible

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

Achmed Jones posted:

my c++ is definitely c with classes

what’s a good place to learn how to write modern c++?

any of Kate Gregory’s stuff. she’s able to bring you up to speed on stuff quickly. I think it’s all through pluralsight though.

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

MALE SHOEGAZE posted:

rust has many problems, not being explicit enough just doesn’t seem like one of them

rust is cool, but I feel like I’m fighting api decisions more than anything else

also rustconf was cool

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

tinaun posted:


yeah it was, i had lunch sitting next to like half the core team and never felt so inadequate

i sat next to some ex-c++ users and we all talked about build systems because of course we did since i was present

im gonna be working with Alex to improve the cmake crate though, and also add meson reading support

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

c tp s: i've finally snapped. i've forked gnu m4 and i'm rewriting it in C++17. I already ported the autotools portion over to cmake, and have ported a few files. its gotten to the point where the wget maintainer is following me and asking if i could please make it run faster. once the fork is semi-working im gonna take a stab at all of autotools to see if i can put together some sort of metadata extractor so you can at least get info on an autotools project in json or some bullshit so you dont have to run a configure script. i've spent like 3 days working on this port, and im worried im going to be the youngest person alive with experience regarding the m4 codebase

edit: by semi-working i mean it passes all tests on macOS and Linux, and sorta works on windows under msvc

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

akadajet posted:

why are you doing this, again?

stepping stone to see if I can write a tool to extract build info and metadata from an autotools based build. if successful, it’ll help most of the effort in the c and c++ communities when it comes to dependency management

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

VikingofRock posted:

For what it's worth this RFC just got accepted so rust's Error trait should improve soon™.

There's also Boat's Failure crate which is neat.

(C++20 is going to have a stack trace API, so error reporting should improve there as well)

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

eschaton posted:

I know this is supposed to be a safe space and all but


wha the Christ

i dunno man it’s been fun so far to destroy all the old busted code and get this working on windows :v:

Slurps Mad Rips fucked around with this message at 04:01 on Aug 26, 2018

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

Luigi Thirty posted:

speaking of things that are busted, the entire STL in VC6

yeah thats dinkumware for you. MS doesn’t contract with them anymore. it’s also why lots of gamedevs wrote their own stdlib stuff for the next decade or so :v:

if you need an STL for that time period I recommend you look into STLPort. there’s deffo a version that supports vc6 somewhere on sourceforge. also maybe grab the last version of boost to support vc6 so you can get decent string/vector implementations

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

pointsofdata posted:

im gonna fake my own death, move to belize south of france, and try to get a sweet remote consulting contract. wish me luck

Nice?

edit: the city

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

DONT THREAD ON ME posted:

how should I do exception handling? I'm most comfortable with Either's and saw someone recommend using them but no idea if that's a good idea or not. I'd rather learn to do what actual real programmers programming C++ do which I'm guessing is exceptions.

you can do both! The best part is you can move between the two and your choice won't be wrong as long as you don't treat the non-exception error-handling like a C programmer who went into a coma in the 80s and woke up yesterday. One thing you'll run into is "How do I construct an object and make sure it never throws?" since you're coming from Rust you just do what Rust does. Static member function, returns an either (we call ours expected, but there's also outcome and that one is a bit better refined). Want to quickly wrap a function that *might* throw and have it turn into an expected? You get to use one of the least well known features of C++: using try blocks as function bodies

C++ code:
template <class... Args>
expected<invoke_of_t<Args...>> safe_invoke (Args&&... args) noexcept try {
  return std::invoke(std::forward<Args>(args)...);
} catch (...) { return std::current_exception(); }

struct T { int x; };

auto x = safe_invoke([] { throw &T::x; });
welcome to the nightmare :v: (im legit gonna try to remove the ability to throw a member pointer for c++20, but you can do this now if you hate life)

tbqh he community is extremely split between people who say "no, exceptions are terrible for high performance code and here's a bunch of proof and examples", people like Herb Sutter who think there's something we can do to bridge the gap (but misunderstanding error handling approaches from other languages) and then people like Bjarne who say "software engineers should write software and leave language design to designers such as myself". (remember, the vasa sank because jet fuel can't melt wooden beams)

if anything though, c++ has some decent capabilities for bridging schools of thought. private inheritance gets you mixins and composable interfaces. public inheritance gives you (in the case of a virtual destructor) class 90s OOP. protected inheritance gives you a bridge to go from public hierarchies to a private hierarchy while keeping both interfaces satisfied. (protected inheritance is "i know that myself is-a Base, but to everyone else I look like has-a Base interface")

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

DONT THREAD ON ME posted:

the reason the borrowchecker is failing is because it is illegal to move out of borrowed content in rust. it's one of the rules of the language. it's not aware of why it's bad. so yeah, it's absolutely opaque. i agree.


hey this is confusing me. what's the relationship between shared_ptr and Box in rust?

the same relationship between Arc and Box in rust. except we don’t have an Rc, though my retain_ptr paper might pave the way for one eventually.

eschaton posted:

why did Rust go with its memory model instead of something like ARC where the semantics are a bit less opaque?

with retain_ptr I can do whatever I want with ObjC's ARC bullshit and I can just let implicit copies happen whenever. i bow before no mortal

Slurps Mad Rips fucked around with this message at 06:09 on Sep 3, 2018

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

Luigi Thirty posted:

smart pointers? lambdas? sorry can’t hear you VC6 barely has the ++ part down

tbqh it’s more or less on par with gcc 2.95 which was its main competition when they were released

i need to go find that patch someone did to the half life 1 sdk so you could make mods with gcc 2.95

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

prisoner of waffles posted:

In the case where there are no fields and all methods are pure virtual, yeah, that's quite similar to Java's/C#'s/Go's/ God knows how many other languages' interface concept

e: technically having _any_ pure virtual methods means the class is abstract, having _only_ pure virtual methods means the class is an interface (?)

sort of. you can still write an implementation for a pure virtual function and the compiler will not complain (nor will the linker)

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

Luigi Thirty posted:

knowing what's in my vectors would be nice


doh ok I don't need the interface at all thanks

also, for future reference, when working with base classes, you can use dynamic_cast and the if assign approach to enter specific type blocks (as long as you know all the types or don't care about anything but one or two)

Something like this if you're stuck with msvc 6
C++ code:
struct Base { virtual ~Base() = default; };
struct Derived1 : Base { };
struct Derived2 : Base { };

void function (Base* ptr) {
  if (Derived1* d = dynamic_cast<Derived1*>(ptr)) {
    // do a thing here
  } else if (Derived2* d = dynamic_cast<Derived*>(ptr)) {
    // do a different thing here
  } else {
    // this is your fallback state in case additional classes are added in the future.
  }
}

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

is it really too hard to use manager/worker, or does that phrasing hit too close to home with how little control we have over our jobs sometimes? :v:

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

brand engager posted:

People care about what that dude thinks about anything?

yes unfortunately


Symbolic Butt posted:

I'm the voice he does here:

im the part where he unironically says "Like a lot of new programming languages are made by people who just are making small stylistic changes..." without any self awareness whatsoever :v:

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

Symbolic Butt posted:

his thesis is something like "she unwittingly wrote an arena-style memory allocator to fool the borrow checker" which seems to be the usual way to go in games written in C++ anyway.

but anyway I still didn't watch the original video by the rust programmer yet but I'm beginning to suspect that she didn't really imply what he's saying she implied, that the "righteous borrow checker guided her to do the right design".

lol but she didn't. jblow has this terrible affliction where he opens his mouth sticks his foot into it and then blames feminism for why he's getting dunked on for his dumb as hell views. please think of this rational, clearly thick skinned, reasonable man's feelings

also, just fuckin' lol at an hour long response to a 5 minute portion of a 45 minutes video he didn't watch all the way through

(also, rust doesn't permit per-container allocators yet, so no, she did not write an arena allocator. she wrote an ecs in rust where she doesnt have to worry about an invalid entity bringing the entire system to its knees)

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

DONT THREAD ON ME posted:

does jblow have fans within the game industry or is his club made out of gamers and aspiring game devs?

from my experience its mostly gamers and people looking to break into the industry. on more than one occasion, quite a few people have described him as "someone who has never suffered a day in his entire life", while others say he acts like someone who "wears a hat that says I'm special on it"

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

Shaggar posted:

I use it when I need to SSH into legacy systems, but beyond that its pointless.

lmao openssh has been shipping natively with Windows 10 for months now what the gently caress are you even doing aside from loving up

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

CRIP EATIN BREAD posted:

windows is a fine OS if you are chronically poor or incapable of using a computer that's connected to the internet. it works well if you treat it like a video game console, its a toy for novel purposes, and the people who spend the majority of using it are pathetic and useless.

eat whats left of my dick

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

mystes posted:

Guess what everyone, Microsoft has a present for you! Not to be outdone by the .net faction's .net core the C++/COM faction has I-loving-poo poo-you-not decided to make what essentially appears to be "COM .net" (which can of course run on Linux) for some inexplicable reason.

https://kennykerr.ca/2018/10/10/xlang/

Kenny is an absolute madman to begin with so I’m shocked that i didn’t hear about this in some capacity at CppCon, but I’m not surprised he’s involved

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

Kevin Mitnick P.E. posted:

c++ is supposed to get modules eventually but millenials killed it. at least i assume we have succeeded by now cause that post is from a year ago. sorry

I'm in the process of updating the style of my site which is why I haven't posted an update on where we are as of san diego, and nothing else has been posted there since the millenials post. We're getting "merged modules", which are a combination of the modules TS and the ATOM proposal. If we can get P1302 added to an appendix in some way, it might even be fun to write modularized c++ :v:

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

elite_garbage_man posted:

Not too loud

Some devs will fire back on how modern c++ is unreadable trash, then brag about how the software they write is too complex for unit tests.

“look in video game development we don’t have time for unit tests. if it looks like it works then it works”, my manager said as he hit “run” in visual studio 2010 and then refused to make eye contact with me as it immediately crashed from a pure virtual function exception.

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

c tp s: I'm trying to (desperately) make sure I never have to touch CMake again (this is a lie, but if it means I have to touch it less often then its worth it) by writing a library that does the common operations everyone does in CMake automatically. Even a few of the maintainers are keeping an eye on it. This means I've been deep into CMake and know it to a degree that the average mere mortal is nowhere near understanding. So here's a small "Everything you never wanted to know about CMake" post

  • contrary to popular belief variables in cmake can be any valid unicode byte sequence the hard part is dereferencing said variable. Want to get the value out of it? You'll need to escape each non-alphanumeric non "-./_" byte. This means you can have variables named 💩that can be set as booleans (since an if() dereferences automatically), but can't actually be dereferenced unless you do some magic byte poo poo and that's error prone.
  • this rule of what constitutes a valid identifier also applies to properties, cache vars, you name it except commands. (macros/functions)
  • add_library(whatever::dude::gently caress::it INTERFACE IMPORTED) is basically how you can have namespaced dictionary types in cmake. These exist at the directory scope (the old pre-CMake 2.8 default scope) and are available anywhere below their definition, but not available above.
  • cmake actually supports "destructors" so you can fire events off at the very end of its configure step. just call variable_watch on CMAKE_CURRENT_DIR and when its set to an empty string you'll know you're done configuring.
  • because cmake treats lists as strings separated by semicolons, a lot of the core cmake devs resort to its internal lovely regex engine for escaping. I said "gently caress that" and decided to do string replacements using the old ascii control code separator units of FS,GS,RS, and US. This allowed me to take the above "dictionary" types and then serialize them to disk. vim and emacs render these files in a not terrible way so the data is still readable.
  • remember above when I said "any valid unicode sequence"? I lied. Properties also permit invalid byte sequences, so I can have a key named INTERFACE_${c0} where c0 is the invalid byte C0 and you can't loving stop me.
  • there are more than just ${variable} style variable references in CMake. There is also CACHE{VAR} and ENV{VAR} references for the CMakeCache.txt and environment variables respectively. You can also make custom variable references like the ones found in the ExternalData module. So I said "Well, what if I had a variable syntax to represent a git repository or a zip file or archive?", so now I can do fetch(HUB{catchorg/catch2@v2.6.0}) because gently caress you
  • generator expressions combined with file(GENERATE) allow you to do things like
    • generate a response file for use in some other target
    • generate a custom toolchain that is invisible to the average person because you injected a custom target_sources command
    • generate a pch which the developers of cmake has said would be hard and impossible to do because they are cowards unwilling to enter into a dark contract with an eldritch demon named "Grant"
    • never have to touch grpc or protobuf's bullshit cmake garbage ever again
    • generate unity builds on a per directory basis

How am I getting this loving shitshow of a library out to people? They put a FetchContent call at the top of their build file and watch the fireworks. You'll only ever use like 5, maybe 6, commands unless you're doing some wacky poo poo like generating an ar script as a hack or whatever.


I loving hate cmake

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

Xarn posted:

Ahahahahahahahahahahahahahahahaha

Hahahahahahahahahahahahahahaha



Currently, modules are developed to satisfy core issues, and build systems are supposed to "just figure it".

What do you mean that modules should have easy mapping from name to their defining file? I see no reason why module butts can't be conditionally defined in file pretty-butterfly.cpp or ugly-moth.cpp.


(Since you are on Slack, you can depress yourself by reading the SG15 channel :v:)

Also make sure to read the notes from our recent telecon because we’re finally loving doing stuff. we have another telecon next week.

luckily, a few people are listening to me now that they’ve seen it with their own eyes despite me raising hell over this since October of 2017. apparently some people thought I was being alarmist and then recently realized I wasn’t :v:

the one good thing that came out of that telecon was getting the author of the Modules TS to agree that compiler devs aren’t putting enough effort into their frontends. fingers crossed we can get something into C++20 but I’ll know more in a few weeks after Kona happens.

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

ratbert90 posted:

I used to use CMake, but then I switched to Meson.
I don't think I will ever go back to CMake except as a thin wrapper to call meson so I can use CLion.

the author of meson is cool and chill and i like the new logo. the recently added support for cmake in meson is pretty good too. the only reason im doing all this work is that there is some stuff i need meson to do that it cant right now. i think im also waiting on the wrapdb support to allow naming local directories

also i wish i could just dump a json/yaml/toml/whatever the gently caress file into meson for basic key-value pair definitions but oh well

once im done with this cmake project i can start working on my 'modern' build system in earnest again :v:

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

Oneiros posted:

power move

i wish i could embed animated gifs in mine but i’ll settle for blowing up my coworkers’ inboxes with them in github comments

https://gitmoji.carloscuesta.me/ :v:

Adbot
ADBOT LOVES YOU

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

eschaton posted:

you do so much cool poo poo with each one though

seriously, I wish I had half the motivation she does to work on stuff.

instead I’m over here writing cmake so no one else has to suffer

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply