« first day (745 days earlier)      last day (4429 days later) » 

00:00
No
@Pubby i think it's a good idea to have a separate heap for each thread, so to avoid synchronization on memory allocations. but it's a belief based on experience long ago. i don't know how it measures up now.
user142019
The point of pointers is to point to objects.
well right, but i mean in terms of creating new objects
user142019
You create new objects like this:
user142019
int main() {
    MyClass my_object;
}
00:01
and that puts it on the stack, right?
user142019
Depends on the context.
user142019
In that case it’s on the stack yes.
user142019
But the C++ Standard doesn’t say anything about stack or heap.
i see
user142019
And the programmer doesn’t care.
Ell
Ell
00:02
a pointer can still point to sometihng on the stack
Use stl containers whenever possible
        C           +--+
        C#          +------+
        C++         +-------------+
        Java        ++
        JavaScript  +---------+
        Lisp        +---------------+
        Prolog      +-------+
        Haskell     +------------------+
        Factor      +-------+
        Bash        ++
        Erlang      +----------+
        PHP         +
        Python      +---------+
        Ruby        +-------+
user142019
std::vector, which is an array, obviously puts the objects on the heap.
user142019
int main() {
    std::vector<int> array_of_ints{1, 2, 3, 4, 5}; // ints are on the heap in like all implementations
}
static arrays are stack or heap based?
user142019
00:03
@Borgleader depends on their superobject, if they have one.
@Zoidberg'-- Those ints are on the stack??
user142019
@Pubby ugh brainfart.
char[] letters = {'a', 'b'} ?
user142019
@Borgleader depends on where the array’s superobject is.
Stop caring about stack/heap
00:04
how do you format code in this? lol
Unless you're optimizing
user142019
@Josh Ctrl+K
cool thanks
@Pubby PHP -
user142019
@MooingDuck no, it should point in the other direction. :P
00:06
@Ell right, but when you instantiate like is
MyClass* object = new Myclass();
it puts it on the heap, no?
user142019
Yes
PHP ERR_UNDERFLOW
Ell
Ell
yeah, but remember it's the new MyClass() putting it on the heap, not the MyClass* bit
@Josh smart pointers
00:07
@Zoidberg'-- Never say never
Ell
Ell
but you should prefer MyClass object;
user142019
@Pubby Okay, only use new for implementing make_unique because the C++ Standard Library is a piece of shit.
@Pubby In this case it might be warranted, although I would have said: Avoid it like the pest.
user142019
@Ell no, you should prefer MyClass object;.
@Zoidberg'-- in which case the LHS is a unique_ptr, so "never do that" is still correct
@Ell auto
user142019
00:07
@Ell use auto, this isn’t some moronic language like Java. :P
Ell
Ell
someone else teach :L
user142019
If you need polymorphism, use std::unique_ptr<T> or wheels::value_ptr<T>. If you need shared ownership (99.999% of the cases you don’t), use std::shared_ptr<T>. If you need null, use boost::optional<T>. Otherwise use T. Very roughly.
2
@Zoidberg'-- you missed array->vector, but otherwise, looks good
user142019
If you need an array, use std::vector<T> or std::array<T, N>.
Ell
Ell
use std::array<> for fixed-size array and std::vector<> for dynamic sized
is an std::map<> usually implemented as a hashtable?
00:12
Why don't you guys shove that in the FAQ so we can just link it next time
:)
user142019
@Borgleader I will make a Gist.
@Ell No, and it can't be
no hash interface
std::map is almost always rb-tree
Ell
Ell
how is it usually implemented? I always invision two vectors, of of key type and one of value, but thats far too naive
okay. I don't really get rb-trees, guess I should read up on them
@Ell an rb-tree is a balanced binary tree
or almost-balanced
it supports efficient rebalancing
00:15
@Ell unordered_map is the hash type
Ell
Ell
but a map is ordered?
@Ell yes. if you iterate from begin() to end(), they're sorted.
Ell
Ell
can you iterate through the keys of an unordered_map?
user142019
I’m open to improvements. gist.io/3977516
@Ell yes, but it's slow.
Ell
Ell
00:16
so what order does it go in? o.O
I always thought this about iterating through a set. How does it choose the order? o.O
> If you need polymorphism, use std::unique_ptr<T>
Ell
Ell
@MooingDuck sorted in what order? as in, numerical? or insertion order?
should be "if you need dynamic, unique ownership"
@Ell "least" to "greatest" depending on the comparitor passed to the map. std::map<key, value, comparitor, allocator>. Default is std::less<key>
Ell
Ell
Right okay
00:19
though with the allocator you can put them in any ordering you want.
One person I saw wanted his stuff like: first even numbers from least to greatest, then odd numbers from greatest to least. And we made a 3 line comparitor to do that :D (I never did figure out why he wanted that order)
user142019
@Pubby of course. Fixed that.
0
Q: Access violation writing location on return

GerardoIn the following code: void A::setAttr(string nombre, string value){ map<pair<string,bool>, int*>::iterator it; for(it = attrInt.begin(); it != attrInt.end(); ++it){ if(it->first.first.compare(nombre) == 0){ *it->second = atoi(value.c_str()); ...

user142019
Hhahahaahha pointers.
atoi in C++ code?
user142019
Why are people not telling him to not use owning raw pointers.
00:28
It makes me sad every fucking time
@MooingDuck Do I get bonus points for being Ultra Helpful(TM) here?
I updated the question with the class to deserialize. this is just a part of a huge xml and a huge deserialization class. So I cant change now to use linq to xml :( hopefully there is a way out — user1186390 34 mins ago
it always goes like: hi, i my program crashes on the line after *mysteryPointer = value, of course the definition of mysteryPointer etc. is irrelevant so I don't show that, what could it be? ... [lots of comments] oh, i fixed it!
I added another answer... catering for the OPs changed question. I must be mad :)
"The Stack Exchange network may be temporarily unavailable while we fail over to our Oregon data center due to Hurricane Sandy. "
@sehe right :-)
Yesterday I was all like "I'll make my own LINQ like C++ interface" who am I kidding I have no clue how to do that
00:32
Gives new meaning to the "Sandy Bridge" name
user142019
I think my favorite SO question code is stack<boost::any>.push(std::priority_queue) stackoverflow.com/questions/11231834/… (10k+ rep)
@Zoidberg'-- lol
@MooingDuck I remember
@Zoidberg'-- i think oregon was known for nutmeg frauds. i may be wrong though
Ell
Ell
@MooingDuck linky?
user142019
00:33
@MooingDuck lolwat
user142019
A stack of priority queues.
but as i recall, them enterprising persons carved nutmeg nuts out of wood and sold them as real thing
user142019
Priority queues are fucking awesome, by the way.
@Zoidberg'-- Nah. He wanted a type to 'store the STL'
@Zoidberg'-- he wanted a stack of the stl types. Not instances.
user142019
00:33
lol
Ell
Ell
ahh I need rep
oh sorry, that's CONNECTICUT
user142019
@MooingDuck he could store std::type_info objects. :P
user142019
Or factory functions that return boost::any.
Ell
Ell
any tasted egg nogg?
00:43
@Zoidberg'-- is type_info really std:: ?
user142019
@CaptainGiraffe uhm yeah?
@CaptainGiraffe it's implementation is ABI specific, but it is standard
@Zoidberg'-- duh yeah
@sehe I pulled my gun way too soon on that one.
Never too soon :)
@sehe Also any references why the type_info name looks so funny?
user142019
00:47
Man. I’m feeling hypnotized.
user142019
@CaptainGiraffe It's not supposed to be human readable.
@CaptainGiraffe I didn't know it looks funny. Seems just like unique_ptr, unordered_map, lock_guard piecewise_construct, really
@LucDanton Still my class name is there =)
Ah, it's more of a "it's not required to be pretty to humans".
00:49
What is it used for?
I feel a SO question brewing.
Since the exact value is implementation-defined, it depends on your implementation.
Ell
Ell
I think just comparing two.types
for equality
Yes and of course, is there any use for that, compiler linker or other
@Ell No, that would be Java style thats not it.
Is there any way I can write a C++ function so that I can call it this way: int count = countIf(a > 3); ?
Is this still about the value of name or about std::type_info in general?
00:52
uh, yeah
int count(bool b) { .... }
@Borgleader Lookup Boost.Phoenix.
a > 3 is just an expression
by a > 3 I mean a lambda without the whole [](int a) { return a > 3; }
maybe something shorter like a -> a > 3; ?
in that case look up placeholders in the std lib
Standard placeholders won't be of much help.
00:54
@LucDanton why do you think they won't help?
The documentation to std::bind would be more useful.
wow, my university never had a data structures course
@Borgleader You mean, a lambda but with a trivial bit of syntax cut?
Pretty much
you won't get more concise than a lambda, I'm fairly certain, even with a bind in this case.
4 mins ago, by Luc Danton
@Borgleader Lookup Boost.Phoenix.
00:57
maybe std::bind(std::greater<int>(), _1, 3), but I don't think that's shorter
Boost's Phoenix/Lambda might have something
Ell
Ell
countif($[int a, int b] {return a < b;})
isn't it something like that?
I love c++ because I can easily convince OO border cases to use RAII. When anybody asks me about virtual, I toss them over to the UI guys.
Ell
Ell
meh I don't know lambda syntax
Boost phoenix is the only way? Didn't seem to be included here: github.com/pfultz2/Linq
Well you can hand-write your own thing with Boost.Proto but Phoenix is in fact implemented via Proto. Also I don't recommend using Proto if you've never used Phoenix.
What's your objection against Phoenix anyway?
01:00
@Borgleader that's nice syntax
@LucDanton I hate compiling boost, it takes 30 min and over 2GB
Fine, don't compile it.
Suit yourself!
oh, his description for this was "The missing link for C++"
What a pun.
01:04
He sure has a lot of libraries.
user142019
@Rapptz Quality is more important than quantity.
I can't judge their quality so..
user142019
Clojure is awesome and I love its syntax.
You should speak with Cat about that.
He'll love to tear your joy apart.
But I also like Clojure.
user142019
Hahahahahahahahaahahahahahahahahahah the Cat, as if he can change my opinions.
user142019
01:13
I’m only unsure on how to do indentation yet. This is the first time I work with a Lisp dialect.
user142019
(defn fact
    "Calculate the factorial of a given number."
    [n]
    (if (< n 2)
        1
        (* n (fact (- n 1)))))
it looks all righty
Find an editor that does it for you.
notwithstanding @sehe's facetious comments about my formatting ability
@Cheersandhth.-Alf ...
01:14
the main thing is just to be really systematic. after that, supporting the human vision system is an advanced exercise. very few master that and it doesn't have good tool support, so may cost more than it's worth.
user142019
Why do I need to sign in to see them.
Dunno.
I actually didn't know that.
it's not publicly shared either
user142019
@StackedCrooked I requested permission to view it.
user142019
Slow Google Docs is slow.
user142019
Oh yeah I got it.
so, it's like, a lisp like small language implemented in java, is it?
isnt clojure javascript?
user142019
@StackedCrooked I use Leiningen instead of invoking the jar directly.
user142019
01:20
@Borgleader uh it doesn’t even come close.
user142019
@Borgleader you may be confusing it with CoffeeScript or ECMAScript.
@Cheersandhth.-Alf Yep, Clojure is a basically Lisp dialect for the JVM.
It also has STM.
Software transactional memory.
oh that's for process communication is it?
user142019
@StackedCrooked TIL your real name.
@Cheersandhth.-Alf It doesn't need to be, you can just use threads. Actually jalf wrote a stm library for c++.
user142019
01:23
I know Java’s I/O libraries are orgasmic as fuck.
I think STM is like subversion. You check out, edit, and the commit. If somebody else commited before you, then you revert your changes, checkout again, edit again, and try to commit again. Etc. (Well, that's not really how I use subversion but you get the point.)
user142019
Never used them though.
@Borgleader I believe there are implementations of Clojure for JVM, .NET/CLR, and JS (though JVM is pretty clearly the primary target).
I heard about Clojure in a web class and I was under the impression it could be used as a replacement for JS
meh... hurricane season...
user142019
01:26
@Borgleader There is a Clojure-to-JavaScript compiler.
user142019
@Borgleader They probably used it server-side, not client-side.
01:40
... I closed FF to clean my temp files and now I cant log in to SO on my laptop because log in is disabled
Go to hell Sandy
user142019
@StackedCrooked the following two are the same thing, right?
The following two?
user142019
(Still typing :P)
Quietly typing?
user142019
(def sq
  (fn [x] (* x x)))

(defn sq [x]
  (* x x))
01:44
It's been two years and I'm a little rusty. But I think those are equivalent.
But it's (* x x)
Instead of (x * x).
user142019
@StackedCrooked Oh yeah of course. :P
user142019
lol Futurama
user142019
> Impossible; you can’t go faster than the speed of light.
user142019
> Exactly, that’s why professors increased the speed of light in 2020.
user142019
02:27
Hmm a cyclops with an eye patch.
oh hey, the site's back
user142019
Why do they have a data center near the ocean anyway.
user142019
And why did they move to another state near an ocean.
user142019
Why not in the middle of the country where hurricanes don’t visit.
what natural catastrophes occur in the middle of countries?
user142019
02:36
Orgasms.
user142019
Oh fuck, tornados.
user142019
Never mind then. They should move to the Netherlands.
does anyone know anything about reading live memory of an arbitrary exe?
i am trying to use autoit to read pixels but it's terribly slow; it'd be much faster to just acquire the game state by somehow tapping into the memory of the program
user142019
Something like ptrace or a debugger framework should do the job.
user142019
02:39
Well, what I said.
user142019
ptrace is a system call found in several Unix and Unix-like operating systems. By using ptrace (the name is an abbreviation of "process trace") one process can control another, enabling the controller to inspect and manipulate the internal state of its target. ptrace is used by debuggers and other code-analysis tools, mostly as aids to software development. Uses ptrace is used by debuggers (such as gdb and dbx), by tracing tools like strace and ltrace, and by code coverage tools. ptrace is also used by specialised programs to patch running programs, to avoid unfixed bugs or to overcome s...
interesting
user142019
If you’re on Windows, there’s probably something similar for it.
Sounds like it would require admin access to be able to read another process' memory.
i am basically trying to analyze puzzle quest
so i can read from memory what kind of piece is in which spot
02:43
@Cheersandhth.-Alf Depends on the country, and exactly what you pick as the center. For example, I'm reasonably close to the center of the US (probably a bit west and south of center, but still a long ways from the ocean). It's pretty hard to come up with major disasters here. Hail destroys peoples' roofs, but but that's about it.
user142019
@Mysticial usually not if you invoke the process; if it’s a subprocess.
user142019
At least not on OS X and Linux, AFAIK.
Does a nuclear war count as a catastrophe?
is there any way to isolate something in game state?
Maybe it counts for an apostrophe.
02:44
Or wait, that's not a natural catastrophe. But it might as well be.
Nuclear war is unlikely, .. I hope.
@Zoidberg'-- Same on Windows. Spawn a program, you have full access to it. You read its memory with ReadProcessMemory.
Nuclear weapons are more like means to scare other nations away from attacking you.
@StackedCrooked At least in the current era, we don't have to worry about nuclear war between superpowers. Nobody wants to die. The only issue is in the rogue states.
You mean like Iran?
Maybe there is a rogue state that wants to nuke Belgium.
02:46
I shouldn't say "states". But rather "groups".
That would be scary.
@StackedCrooked ...and North Korea.
A small terrorist group with a bunch of nukes could be problematic.
@JerryCoffin Yikes, I didn't know they had nukes.
@StackedCrooked I think the biggest danger in Belgium would be Flanders deciding to get rid of Wallonia (or vice versa).
02:47
You could secretly plant one under every major city in the world. And detonate them all at once.
@JerryCoffin That's also unlikely I think.
@StackedCrooked I don't think they do right now, but there's been talk that at times they were probably working on developing them.
finally SO is back up... I was starting to go into rep withdrawls...
user142019
@StackedCrooked The Netherlands?
@JerryCoffin Just read on Wikipedia that they did their first nuclear tests in the 50's. Oh wait, it was 2006.
02:48
@JerryCoffin They definitely have them. Or at least a fizzle nuke that doesn't completely work.
> In May 2010, the Rodong Sinmun announced in an article that North Korea had successfully carried out a nuclear fusion reaction.
Lol.
user142019
Slowpokes.
A suitcase nuke is a tactical nuclear weapon which uses, or is portable enough that it could use, a suitcase as its delivery method. Synonyms include suitcase bomb, backpack nuke, mini-nuke, and pocket nuke. Thus far, only the United States and the Soviet Union/Russian Federation are known to have possessed nuclear weapons programs developed and funded well enough to manufacture miniaturized nuclear weapons. Both the United States and the Soviet Union have acknowledged producing nuclear weapons small enough to be carried in specially-designed backpacks during the Cold War, but neither ha...
@StackedCrooked Nothing to laugh about (most nukes are fusion, not just fission).
"Soviet Union" is a bit dated?
02:50
@Cheersandhth.-Alf "are known to have posessed"
@Cheersandhth.-Alf Yeah, a little.
The US has the "Swan Device".
user142019
All countries have nuclear weapons. Except maybe the Pitcairn Islands, a country with a population of 67 people.
@Mysticial Yeah, they claimed to, but IIRC there seemed to be some question about whether it was real or not at the time. I haven't seen much of anybody claiming they have much in he way of an ongoing program though.
Overkill is the use of excessive force or action that goes further than is necessary to achieve its goal. It implies that, while the goal was accomplished, there was collateral damage as a result. It may be a literal term referring to physical damage, though it is also used in colloquial conversation as a metaphor. Nuclear weapons Overkill is especially used to refer to a destructive nuclear capacity exceeding the amount needed to destroy an enemy The term is attested from 1946 and was in common use during the Cold War era, referring to the arms race between the United States and the Sov...
02:54
@Zoidberg'-- Germany doesn't.
user142019
@melak47 They do.
user142019
They just don’t tell.
@Zoidberg'-- not any of our own, no
user142019
Don’t be naive.
maybe that's why they can't find that waste chamber in the underground nuclear waste storage site!
they made bombs with it :p
02:57
I once saw a documentary about North Korea. The common people there seemed to be very nice and friendly. They have their little ambitions and all. It was a little heartbreaking actually.
user142019
@melak47 Not that they’ll ever use them, it’s a bit like why lions have large manes.
user142019
Using nuclear weapons is dumb.
user142019
@StackedCrooked I have seen two.
@Zoidberg'-- an invisible mane isn't very helpful in that regard :/
02:59
Apparently, it's pretty easy to make a basic nuke once you have the materials.
user142019
@melak47 All world leaders know it. :P
@Zoidberg'-- You must have been devastated.
user142019
@StackedCrooked I have seen Welcome to North Korea and Floortje Dessing in Noord Korea.
It's the hydrogen bombs which are trickier because the technology on how to keep the bomb from falling apart before fusion begins is still classified by the US and the Soviets.
@Mysticial A really basic nuke is really pretty trivial. Most of the complexity in a nuke is to make sure it doesn't detonate except when wanted.

« first day (745 days earlier)      last day (4429 days later) »