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.
 
  • Locked thread
fritz
Jul 26, 2003

quiggy posted:

yup, c++03 for me


i believe this is no good. the whole reason for doing it back-to-front is to avoid invalidating iterators with erase. erase invalidates both the iterator passed to it and all iterators past that, but not iterators before it. by walking the list in one direction and storing the iterators in a stack, then popping the stack, we can remove iterators back-to-front and avoiding walking the original list multiple times to get valid iterators

i believe (although feel free to correct me if i am mistaken) that one reverse_iterator is "past" another if it points to an earlier object in the list. thus reverse_iterators just flip the problem and do not solve it

yeah, erasing one at a time means you gotta do it in that order, or else. you could store indices instead of iterators, but then you'd still have to go thru it backwards

are you memory limited b/c i would have written it as:
code:
std::set<size_t> skip;
for(size_t i=0; i < data.size(); i++) {
if (whatever) { skip.insert(i);}
}
std::vector<eh> out;
out.reserve(data.size() - skip.size());
for(size_t i=0; i < data.size(); i++) {
if (skip.count(i) == 0) { out.push_back(data.at(i));} 
}
std::swap(out, data);

Adbot
ADBOT LOVES YOU

fritz
Jul 26, 2003

Bloody posted:

I literally cannot even guess what [&] might do

something like 'variables used inside the body of the lambda are copied-by-reference from the enclosing scope'

im against it b/c you're playing with fire if there's a chance of things going out-of-scope before the lambda gets called

quiggy
Aug 7, 2010

[in Russian] Oof.


Bloody posted:

I literally cannot even guess what [&] might do

i know the [] before the lambda indicates those variables are captured from enclosing scope, so i assume that says to capture by reference or something

fritz posted:

yeah, erasing one at a time means you gotta do it in that order, or else. you could store indices instead of iterators, but then you'd still have to go thru it backwards

are you memory limited b/c i would have written it as:
code:
std::set<size_t> skip;
for(size_t i=0; i < data.size(); i++) {
if (whatever) { skip.insert(i);}
}
std::vector<eh> out;
out.reserve(data.size() - skip.size());
for(size_t i=0; i < data.size(); i++) {
if (skip.count(i) == 0) { out.push_back(data.at(i));} 
}
std::swap(out, data);

vector::erase() requires an iterator as the argument, so i've gotta have an iterator somewhere. might as well just store them because im not super memory limited. i am time limited however; the whole of this particular project needs to run in less than 10ms/cycle. the fewer lookups i can do on a specific object, the better

kitten emergency
Jan 13, 2008

get meow this wack-ass crystal prison
we had a separate qa team and dev team until a few weeks ago when the product exec reckoned the reason we were always late shipping new versions was because the qa team was bad at testing

so they fired half the qa team and made the other half devs and said that devs do testing now

this is going about as well as you might expect

raminasi
Jan 25, 2005

a last drink with no ice
unless i'm misreading (and i very well may be) y'all are getting confused by the totally reasonable intuition that remove_if actually removes things from the container

it does not

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
oh my god these fonts feel amazing on my eyeballs

https://blog.golang.org/go-fonts

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

MALE SHOEGAZE posted:

oh my god these fonts feel amazing on my eyeballs

https://blog.golang.org/go-fonts

lmao

Bloody
Mar 3, 2013

lol

Bloody
Mar 3, 2013

Bloody posted:

i strongly dislike the use of var in c# because i once came across a project that exclusively used var and in trying to read it i almost died because it was pointlessly hard to read and using intellisense to figure out what every loving method returned so i could have some idea of what the hell was going on in this program was pointlessly inconvenient

wow look at this idiot

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

Bloody posted:

wow look at this idiot

lol

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Bloody posted:

wow look at this idiot

var is good, and type lookups only take me three key presses. maybe fix your editor if looking up types is difficult.

jony neuemonic
Nov 13, 2009

Bloody posted:

wow look at this idiot

lmao. yeah, i was never a var hater but i was always pretty shy about using it for anything but explicit-type-on-rhs (so basically var butt = new Butt() and nothing else).

then i just said gently caress it, started using var for everything but primitive types. turns out the sky didn't fall and i can still understand my code??

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder



looks phenomenal in emacs on my retina display. I love the playful-yet-seriousness of it, like go itself.

jony neuemonic
Nov 13, 2009

a hideous font for a hideous language.

triple sulk
Sep 17, 2014



MALE SHOEGAZE posted:



looks phenomenal in emacs on my retina display. I love the playful-yet-seriousness of it, like go itself.

lmao @ everything in this screenshot

triple sulk
Sep 17, 2014



- not windows
- not visual studio 2015
- not c#
- not one of consolas, source code pro, or hack

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

MALE SHOEGAZE posted:



looks phenomenal in emacs on my retina display. I love the playful-yet-seriousness of it, like go itself.

it looks like the Roman lettering in the typical Chinese font

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
it's source code pro when I'm not in go-mode

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
trying it out now

my first impression is that the monospace version is too serify for my liking, but the proportional one is pretty needs-suiting

Mao Zedong Thot
Oct 16, 2008


triple sulk posted:

- not windows
- not visual studio 2015
- not c#
- not one of consolas, source code pro, or hack

Correspondingly:
- don't want to hang self

Mao Zedong Thot
Oct 16, 2008


I mean, consolas is p good tho

triple sulk
Sep 17, 2014



VOTE YES ON 69 posted:

Correspondingly:
- don't want to hang self

why would using the best development toolset (visual studio and c#) make you want to hang yourself

leftist heap
Feb 28, 2013

Fun Shoe
that font looks like it's out of a lovely 90s cs book so it's goddamn pitch perfect for Go lmao

leftist heap
Feb 28, 2013

Fun Shoe
"hey remember that old dumpster we fished Go out of? maybe we could go back and dig out the font we used for code examples in practice of programming!!" - rob pike

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
best coding font for best language and development environment

anthonypants
May 6, 2007

by Nyc_Tattoo
Dinosaur Gum
but what does it look like

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

anthonypants posted:

but what does it look like

lots of examples courtesy Ralf Moeller

the very bottom one is similar to how one could read the forums if Radium 2.0 enables the creation of an NNTP gateway

VikingofRock
Aug 24, 2008




MALE SHOEGAZE posted:



looks phenomenal in emacs on my retina display. I love the playful-yet-seriousness of it, like go itself.

lol what kind of baby uses syntax highlighting when writing go

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av

MALE SHOEGAZE posted:



looks phenomenal in emacs on my retina display. I love the playful-yet-seriousness of it, like go itself.

it looks like the default japanese font for latin characters

redleader
Aug 18, 2005

Engage according to operational parameters

raminasi posted:

unless i'm misreading (and i very well may be) y'all are getting confused by the totally reasonable intuition that remove_if actually removes things from the container

it does not

ok what

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

it removes "ifs" from the code

qntm
Jun 17, 2009

ahahahaha I just looked it up, expecting that it would just return the new pbegin iterator which would skip the filtered entries but nooooooooope

here's the example code

C++ code:
// remove_if example
#include <iostream>     // std::cout
#include <algorithm>    // std::remove_if

bool IsOdd (int i) { return ((i%2)==1); }

int main () {
  int myints[] = {1,2,3,4,5,6,7,8,9};            // 1 2 3 4 5 6 7 8 9

  // bounds of range:
  int* pbegin = myints;                          // ^
  int* pend = myints+sizeof(myints)/sizeof(int); // ^                 ^

  pend = std::remove_if (pbegin, pend, IsOdd);   // 2 4 6 8 ? ? ? ? ?
                                                 // ^       ^
  std::cout << "the range contains:";
  for (int* p=pbegin; p!=pend; ++p)
    std::cout << ' ' << *p;
  std::cout << '\n';

  return 0;
}
the actual value of myints[] at the end of this program?

{2,4,6,8,5,6,7,8,9}

qntm fucked around with this message at 11:48 on Nov 17, 2016

redleader
Aug 18, 2005

Engage according to operational parameters
so it prints 2 4 6 8 and absolutely fuckin destroys the original array? neato

i'm terrified by what it could/would do to a more elaborate data structure

i'm sure there's a really good and graybeardy reason for this, but holy poo poo give me a well-behaved, intuitive, modern lang any day

redleader
Aug 18, 2005

Engage according to operational parameters
on the topic of modern langs, here's a summary of the new features in c# 7

tuples will be nice to have. everything else strikes me as being pretty niche or situational from initial impressions

Fergus Mac Roich
Nov 5, 2008

Soiled Meat

redleader posted:

so it prints 2 4 6 8 and absolutely fuckin destroys the original array? neato

i'm terrified by what it could/would do to a more elaborate data structure

i'm sure there's a really good and graybeardy reason for this, but holy poo poo give me a well-behaved, intuitive, modern lang any day

No no, it just isn't able to resize the container for you since it works on any forward iterator. The items that meet the requirements of the predicate are moved to the start of the range, the rest you can't depend on having any particular value. The docs explicitly mention you need to use your container's erase method or what have you to actually resize the container. I could be missing something, after all I am represented by the thread title, but this makes perfect sense to me

Fergus Mac Roich fucked around with this message at 12:10 on Nov 17, 2016

qntm
Jun 17, 2009
the one which caught me out is when you access a map element which doesn't exist, C++ just adds a new element to the map and returns it

Fergus Mac Roich
Nov 5, 2008

Soiled Meat

qntm posted:

the one which caught me out is when you access a map element which doesn't exist, C++ just adds a new element to the map and returns it

now that's fuckin crazy, but I guess there isn't a convenient tombstone like in a language where everything is a nullable reference.

qntm
Jun 17, 2009

Fergus Mac Roich posted:

now that's fuckin crazy, but I guess there isn't a convenient tombstone like in a language where everything is a nullable reference.

it is, again, a classic example of something which makes perfect sense if you think about it for an hour but is the very last thing that anybody would actually expect to happen

gonadic io
Feb 16, 2011

>>=

Fergus Mac Roich posted:

now that's fuckin crazy, but I guess there isn't a convenient tombstone like in a language where everything is a nullable reference.

Plus it lets you do
map["butt"] = "fart";

Thus saving you from having to do a lookup then an insert!1

Adbot
ADBOT LOVES YOU

akadajet
Sep 14, 2003

MALE SHOEGAZE posted:

oh my god these fonts feel amazing on my eyeballs

https://blog.golang.org/go-fonts

hey, I always wanted my code to look like chinese fonts

  • Locked thread