« first day (318 days earlier)      last day (4624 days later) » 

9:00 PM
and it's the bestest idea evar to make the default container worse for everyone because some people have to deal with legacy code- amirite?
 
lol, well, a lot of things use legacy code and I guess you don't want to break interop with it, so if you need it that way, then that's the way it's gotta be
but if you don't have legacy code to deal with, then std::vector is good no?
 
no, it's a horrendous idea
 
how did I know you were gonna contradict me?
 
@DeadMG Why do you think std::vector is worst with this feature?
 
well, let's see
you could instead use an unrolled linked list
where you can allocate the nodes from an object pool and make them faster to allocate, offer O(1) remove and insert, for example
not to mention other algorithmic improvements
for no performance loss when the unroll is large enough
 
9:03 PM
@DeadMG Do find the contiguity guarantee dumb?
 
O(1) remove?
 
yes, unrolled linked lists offer O(1) remove
 
Don't linked list have a lot of problems with cache miss too?
 
Only in std::quebec.
 
regular linked lists do
unrolled ones don't
 
9:04 PM
What about random access?
 
HashSet also hash constant complexity.
 
mm, I'm not actually so sure about random access
that's a point I had not thought of
 
I see I'm not the only one suffering from this today.
 
not really, I almost never have the need for random access
 
9:06 PM
Anyway I thought std::vector was designed to replace C arrays.
 
they are
 
Yeah R. Marinho is right random access is pretty useful with some algorithms.
 
that's what I'm bemoaning- I think that an unrolled linked list design would be much superior in most use cases
which the Standard forbids
 
It doesn't forbid it. std::vector simply isn't the place for it.
 
Being a replacement for C arrays, O(1) random access sounds like something to have.
 
9:07 PM
vector is even a bad class name for what it is
 
std::deque can be implemented like that, can't it?
 
yeah
 
@StackedCrooked yea I have never understood why they call it a vector?
 
@TonyTheTiger basically it was a mistake. i believe stroustrup admitted that
 
FWIW std::deque has been at times touted as the 'go to' container to use.
 
9:09 PM
I've heard that too.
 
I fully concur
 
@StackedCrooked oh ok
 
Bjarne recommends std::vector as the default choice for container.
 
@LucDanton what do you mean ?
 
actually, I think that std::string in specific should be implemented as a node-based container
 
9:09 PM
@StackedCrooked I've heard that too, but from STL at MS
 
operations like concatenation could go to O(1)
 
@DeadMG a node per char?
 
no, the idea is that you have, like, 200 chars per node
so that the time taken to process the chars > the time for the cache miss
 
@Drahakar Unless you have a clear requirement that calls for a very specific container (e.g. sometimes an std::map is obviously the container to use), std::vector and std::deque are the containers that are usually advocated.
is how I feel about it.
 
9:11 PM
@LucDanton Ok, thanks for the explanation and the video hahaha
 
Someone once told me that memory copying is fast on Intel processors so you don't need to worry too much about performance when copying strings and vectors. I don't kow if this is true though.
 
@Drahakar Perhaps you're not familiar with std::deque though? Is that what your question was about?
 
@LucDanton I was not familiar with the expression you used :S
 
I don't think I have ever used std::list, except as an exercise when learning about it.
 
interesting way to avoid mowing the lawn
 
9:15 PM
I most commonly use vector, map and set. If I need a stack I also prefer std::vector instead of std::stack.
 
@StackedCrooked I think Herb Sutter is suggesting to use std::vector too
 
I never really got the difference between set and vector...
I've seen set used a lot though
 
Lookup for std::set is logarithmic vs linear.
Although you can compare std::set to a sorted std::vector.
 
@TonyTheTiger A set<T> is like a map<T, T>.
It uses a balanced tree to store its elements.
 
yea a set is actually a type of associative container with only a key, it is always sorted as it is implemented as BST
hmmm
 
9:18 PM
As @LucDanton said, you can think of a set as a vector that is always sorted.
 
interesting...
 
@TonyTheTiger it also can not contain duplicates. which is handy sometimes. For example you can push 10 elements into a set and then ask its length. If the length < 10 then it means you had duplicates.
 
huh?
oh yea
 
There's std::multiset for that.
 
now when would there be a need to write custom allocators for something like a set or vector?
cause I see you can always write one, but I've not seen code that does that
 
9:20 PM
@TonyTheTiger If you want to use a memory pool.
 
The obvious is speed.
But there are other reasons.
 
speed?
 
If you want to keep a vector in shared memory for example.
 
is the default allocator slow?
 
not really
 
9:20 PM
@TonyTheTiger It's not optimized for whatever you are doing.
 
All allocators are slow at something.
 
@TonyTheTiger No but it does good for all the average job. If you havemore specific needs, you can gain some speed by coding your own
 
If you have a std::set then all items are scattered throughout memory when using the default allocator. If you use a pool allocator then the elements will be neatly together in a single chunk of memory.
 
well, I've read that for example doing lots of allocations in a multi threaded program can be a source of contention, as the heap internally holds mutexes while doing an allocation, so perhaps this kind of thing would be a place for a custom allocator?
or am I wrong
@StackedCrooked oh that's interesting to know
 
9:22 PM
Possibly.
Possibly right I mean.
 
Could be FUD, could be relevant for some applications.
 
@TonyTheTiger If multiple threads access the same std::set object then you need to lock before accessing it anyway. That will be your source of contention.
 
@StackedCrooked true, but that could be resolved by using another data structure, where mutexes would be held for less amounts of time, like a linked list. That is if the data structure needs a lot of inserts/removals done from multiple threads. Searching is another thing entirely
 
@RMartinhoFernandes WTF does "Possibly right I new." means?
 
@RMartinhoFernandes you're talking to yourself?
 
9:25 PM
@TonyTheTiger OK. But my answer was in the context of custom allocators for std::set.
 
in a public chat, nice :P
@StackedCrooked sure
 
@StackedCrooked Even if you have a set local to one thread, you can avoid heap allocation which causes contention with other threads.
 
@RMartinhoFernandes Yep, but I think heap allocation in multiple threads does not cause much contention.
 
@RMartinhoFernandes afaik a call to new will cause the heap to be locked, so no other thread can then call new so if that's done lots, it could be a trouble spot
 
Anyway I like the Humble Linear Allocator for its simplicity.
And can be made thread-local.
 
9:31 PM
@StackedCrooked hey cool :)
 
you know, I made a blog post and discussed in here a virtually identical scheme
 
@DeadMG you mean the post about the stack?
 
yep
the pool, you can find in Boost
 
I did some experiments with this Pool class. It is a compromise between a humble linear allocator and a stack. (Disclaimer: experimental, don't start bashing me :D)
 
Oooh code, let's bash review.
 
9:36 PM
Oooh code, let's unsympathetically rip it apart for our own enjoyment!
 
"Do you have code bashing sessions at your workplace?"
2
 
I know you guys all too well...
 
@RMartinhoFernandes Also known as code reviews
 
Yes. That was the joke.
 
@RMartinhoFernandes If have infinite opportunities to do that of my colleages' code at work. However, that would make me the most hated employee there.
 
9:38 PM
namespace nonstd lol
 
ownt
 
cool codez
I'm not experienced enough with memory pools to comment
:(
 
Hi all
 
How do you guys find the standard library functions ? Just by searching online
 
9:43 PM
I usually look on MSDN
 
I just want list of all member functions std::string has
 
Me too.
 
for example
 
I check the standard, or cplusplus.com.
 
@Mahesh usually use cplusplus.com
 
9:43 PM
isn't cplusplus that reference that's known to be utterly hideous and factually incorrect often?
 
It has the signatures right.
 
how reassuring
I'd rather stick to MSDN
 
@Node - The problem is I need to click the link to see the overloads it has
 
9:44 PM
Any file that just list members and also it's overloads
 
Though since there's no complete C++11 reference out there, I've been mostly sticking to the standard draft.
 
cplusplus.com is terrible from a pedant point of view. for most users it's very helpful. :)
 
I use intellisense :)
 
that often works for me too
 
9:46 PM
@TonyTheTiger - VS 2010 is good at it. But what if I am using gedit on linux
 
@Mahesh write it in VS first :P
use VIM
 
+1 for vim
 
we have vim experts here :)
 
9:46 PM
Use jquery
 
@RMartinhoFernandes - Yeah it's very odd to use old editors though
 
Odd?
Is old a bad thing?
 
vim is pure awesomeness, when you know how to use it :P
 
Vim is more common today than you would think.
 
Odd in the sense it doesn't have intellisense. Just it has syntax highlighting
 
9:48 PM
I don't care about what the cool kids are using today (I sound like I'm twice my age). I use vim because I'm highly productive in it.
 
if I amn't wrong
 
@Mahesh You can have completion with ctags and cscope I think.
 
I know several colleagues that use Vim. I only knew one that uses emacs.
 
Does VIM has intellisense feature? How to enable it ?
Any external plugin ?
 
It's called Omni-completion.
 
9:49 PM
@Mahesh yes you have to use the cscope plugin.
 
Go Go Visual Studio
 
Vim isn't the best choice for large-scale C++ development IMO. (It's a great editor, not a great ide.)
 
I got confused the first time I used vim, couldn't figure out how to type anything
 
@DeadMG - With VC++ Next coming up, I think it is going to be even cool
 
yeah, they might actually have Intellisense that doesn't suck
 
9:50 PM
VS is ok. There's VsVim :)
 
then I saw you need to press insert or use ctrl i or something to start typing, lol
 
kinda concerned that their performance will be balls, though
 
@TonyTheTiger It's i (insert). Or a (append). Or a bunch of other different actions.
 
but, I just can't live without the thing where you can select multiple vertical rows of text as well as multiple columns
 
I get a bit worried when they try to add too many features to an IDE
 
9:50 PM
You can configure a key combination in Visual Studio for launching the current file in Vim. Instructions
 
@StackedCrooked Or use VsVim.
 
@RMartinhoFernandes Not familiar with that.
 
@DeadMG Like you can with vim?
 
I've never used vim and wouldn't know
 
@Node are you root?
 
9:52 PM
@DeadMG you can also select blocks of text (not the whole line) and edit them all at the same time, can be useful
@TonyTheTiger eh?
 
lol, root node....
 
ha
 
Vim macros can be incredibly useful for doing large repetitive jobs.
It's like a scripting language without having to write code.
@RMartinhoFernandes But I will give it a try.
 
so if a former male porn star is a teacher, I wonder what he teaches? :P
 
This was the smoothest transition ever.
 
9:57 PM
Is there such a thing as a porn school?
 
lulz, well what certs do you need to go into pr0n?
 
I think I have brain damage or something. My typing wasn't so horrible in the past.
 
I bet you need lots of medical tests for STDs.
 
I would HOPE so for their sake
 
@RMartinhoFernandes Medical knowledge and all. It seems like a very varied program.
 
9:59 PM
although I saw an article about a porn star having HIV being fired recently in LA
is it me, or do I really always bring up sex? lol
 
Oh, you noticed.
 
heheh, lulz
if it annoys you guys just tell me, I'll talk about something else
like the weather or something
 
Like small talk?
 
yea or PROLOG, @DeadMG should then be able to join the conversation
:P
 
Don't poke it!
 
10:01 PM
Has it been a rainy summer for you guys as well?
 
Yes :) (yes, that's a happy face :)
 
oh yes
rain rain rain
 
AAAAH PROLOG DEADMG SMASH AAAAAH
 
lulz
if you only had a hammer and prolog was the nail,
 
I will always remember @DeadMG as that Prolog guy.
3
 
10:02 PM
you could nail it!
 
hey
 
as the prolog puppy you mean, FTFY
 
I'm the Geniusâ„¢
the Geniusâ„¢ puppy
 
I had two PROLOG courses. I hated the first just like the puppy, but I actually enjoyed the second.
 
Wow you got it even trademarked!
The first course must have been for sifting the stupid people out.
 
10:04 PM
so I would prob get sifted after the first course
 
I would probably get sifted on my way to school.
 
lulz
I lol'd
 
Me too. I lol at my own jokes :S
 
PROLOG is just a terrible language
 
I wish when new failed you'd get this response
 
10:06 PM
nobody sane makes their language depend on the capitalization of identifiers
 
Oh, here we go again.
Another case in point: Ruby.
 
and the rant starts again, quick find a distraction!!
 
Go depends on capitalization too.
 
@RMartinhoFernandes Ruby does this well I think.
 
10:07 PM
And Haskell.
 
Java does it too for class names.
 
rant has been averted!!!
 
@StackedCrooked I don't think PROLOG does it wrong. It's a very simple rule.
 
I hope
 
10:07 PM
@RMartinhoFernandes Dunno about prolog.
 
@StackedCrooked No. The syntax of Java doesn't force anything.
 
@RMartinhoFernandes Must be eclipse then.
 
I wonder if Capitalization is self dependent?
 
it's a wrong rule
 
VB.NET is horrendous on capitalizing all things
 
10:08 PM
But it's case insensitive.
 
but it does it for you
damn it
 
That's the IDE.
 
CamelCase on All Things
 
All those I listed are case sensitive and case has semantic meaning.
That second part is what @DeadMG complains about. I think.
 
oh, sorry, being a derp
 
10:09 PM
derp derp
le derp
 
I met derpette today :)
 
Who starred one of my fast-deleted posts? (those with a single dot)
 
Guilty as charged :P
I was trolling
derpness
s my d can have a lot meanings
did I scare everyone away?
:(
 
I'll be jobless in three weeks. I'm updating my CV.
 
I'm playing with Bukkit and MCEdit.
 
10:14 PM
@RMartinhoFernandes that s's your d
 
nothing
 
@RMartinhoFernandes oh why? contract ends?
 
I know how that feels
been in the same derpy situation
 
Stackoverflow should employ us since we are spending most of our time on it :)
 
11:20 PM
Hmm 21 more boats and I get a shiny.
 
A badge?
 
Yeah, what else would a shiny be?
:)
 
But.... you already have the c++ badge. Are the tag badges multi-awardable?
 
I have a bronze one. I'll have silver one when I get 400 upvotes on answers.
And then there's a gold one at 1000 upvotes.
 
Oh, sweet.
I mostly ask in the C++ tag, don't answer that much.
 
11:32 PM
woah, I need one more answer of mine upvoted to hit repcap
it will be my first
anyone?
 
:P
My first repcap hit :) Woot :)
 
You'll get a badge for that.
 
repcap is 200 right?
 
Yes.
This is so... I don't know.
-1
Q: Locking an object in C#?

Dervin ThunkI have the following sample code in some (nonexistent) language: class Node { int val; Lock lock; } What would be the equivalent of that Lock in C#?

 

« first day (318 days earlier)      last day (4624 days later) »