« first day (419 days earlier)      last day (4544 days later) » 

Ell
6:00 PM
yeah i suppose
how does std::map allocate new objects?
would I be right in saying it uses std::allocator?
 
@Ell With its allocator.
 
Ell
or does it just 'new' the,m?
kk - would learning to use allocators myself be a good learning excersie? or are they too complicated for a beginner
well - experienced beginner
 
@Ell Nah, they're just a lot of definitions. The idea is simple.
 
Ell
i have looked at them before
but i got stuck
and wasn't sure if i was using it right
because i made an allocator member
but when i tried to construct() it asks for a pointer to where to make the object
 
@Ell Ultimately they will always use ::new (p) T(x); (C++98/11) or ::new (p) T(std::forward<Args>(args)...); to construct elements.
 
Ell
6:03 PM
but how am i supposed to know where the object will be created?
 
@Ell You decide :-) The standard allocator just calls ::operator new(sizeof(T)) to get memory.
It's actually mandated to do so by the standard.
 
Ell
I decide?
hmm okay
 
You call allocate to get memory, and construct to make objects.
 
The malloc-allocator would call malloc(sizeof(T)), for example.
 
Ell
okay
i will look into them again :)
 
6:04 PM
A pool allocator could use buf + N
 
Ell
yeah
 
Allocators have become much better with C++11 thanks to the emplacing semantics...
 
@KerrekSB It's true that the memory comes from ::operator new, but it's not true that std::allocator<T>::allocate is mandated to use ::operator new(sizeof(T)).
 
... and they're now also allowed to have states.
@LucDanton I'm pretty sure it is...
 
And ISTR that the implementation in libstdc++ is quite clever.
 
6:06 PM
@LucDanton not the size, but it has to use ::operator new()
 
Ell
emplacing semantics?
 
@KerrekSB Well yeah, that leaves quite the room for allocation strategies.
 
Ell
and I am confused about c++11 - is it a standard in the working? is it finished? i have g++ 4.6.1 - does that mean i can use c++11?
or c++0x?
or what? :/ i suppose i should just google it first?
 
It's a complete / finished standard now
 
C++11 was published on September 1. C++0x was the working name.
 
6:08 PM
@Xeo I already had that problem. See this question
 
6
Q: C++11 Compiler: Closest to the standard and how close?

dsimchaI'm interested in learning C++ more thoroughly now that C++11 is apparently ratified. What compiler currently implements the closest thing available to full C++11 support? How close is said compiler to full support? Are there still major features missing or just language lawyer minutiae?

 
g++ 4.6.1 supports a lot of C++11 features.
 
@LucDanton Oh OK, sure. But the point is that if you replace global-new, then the standard allocator will see that.
 
You have to compile with -std=c++0x to enable them.
Future versions will use -std=c++11.
 
@Ell This means that with a combination of variadic templates and perfect forwarding you pass constructor arguments directly, rather than passing a copy of the object.
E.g. v.push_back(T('a', true, 1.5)); vs v.emplace_back('a', true, 1.5);.
 
Ell
6:10 PM
which means you would pass 'a' directly to the constructor as opposed to a copy of it?
but how does that work with literals?
oh wait a minute
sorry yeah i get it now
 
No, the thing is, instead of constructing an object and then passing it to push_back (which will copy it internally to its place), you just give the constructor parameters to emplace_back and it constructs the object directly in its place in the vector.
 
@Ell There's no copy of T...
 
Ell
yeah i get it now, sorry i misread it
 
The allocator supports this. It offers the old construct(T const &), as well as the new construct(Args &&...).
 
@RichardPennington How much of your compiler is complete?
 
6:14 PM
@ManofOneWay Quite a bit since it is based on clang/LLVM. I'm putting a standard library together for it now.
 
user image
2
I know it's late, but I really love making these diagrams.
 
Ell
:0
:)
thnankyou :)
with std::allocator
what do i need to pass to construct
to default construct something?
 
Ell
okay that makes sense :)
 
    if (begin == end)
        throw std::runtime_error("aaaaaah!");
 
6:23 PM
What?
 
a sample from the WideC codebase
 
And...? Seems normal to me.
Well, besides the error message.
 
yeah, that was it
 
Ell
can i have some help with this?:
`mAllocator.construct(mAllocator.allocate());`
im trying to allocate one element and construct it, but this gets a compile error
and doing allocate(1) doesn't help either
 
6:28 PM
@DeadMG Do you have any WideC snippets I could look at?
 
what are the function signatures
 
I haven't finished inventing the compiler yet
what use would I have for it?
 
You've shown an allocator once.
Or something like that.
Maybe that code is no longer valid under current syntax though.
 
You're writing the compiler before creating the language??
 
it's validity was probably dubious to begin with
 
6:30 PM
lol
 
actaully
I think that code was never valid
I wrote it to see if it could work, and the answer was assuredly no
 
@Ell: MSVC's allocators require two parameters to ::construct. What's your construct's signature?
 
New-style allocators don't.
 
@DeadMG You've spiked my curiosity. What's this language project you're working on?
 
Ell
im using g++ 4.6.1 and i dont know how I find out the signature
but according to cplusplus.com its this
void construct ( pointer p, const_reference val );
 
6:32 PM
@Ell cplusplus.com is a shitty reference
 
That's the old-style.
 
Ell
oh :P
 
Also, if anyone happens to feel like taking a stab at a small generics / constraints problem I'm having, take a look in the C# chat really quick: chat.stackoverflow.com/rooms/7/c
 
Ell
what is a good reference?
 
@robjb I would answer you, but I'm busy playing Starcraft right now :P
 
6:33 PM
@DeadMG That's a legitimate excuse :]
 
@RMartinhoFernandes: MSVC doesn't have variadic templates, so construct still takes two parameters: msdn.microsoft.com/en-us/library/y19ftw27(v=VS.100).aspx. Well, except that last one which is a wierd hack.
 
the language's name is WideC
 
But Ell is using GCC.
 
and quite simply, it features an revolutionary compiler design
 
I just checked and GCC 4.7 has the new construct with variadics.
Dunno if that's new in 4.7 or if it was in 4.6 already.
 
6:34 PM
where you can execute arbitrary code at compile-time, and it runs at almost the same speed as at run-tim
instead of D, where it's thousands of times slower
 
@RMartinhoFernandes: yeah, he said that after I made my comment. :D His problem is something else.
 
and types, functions, etc, are first-class values
 
@DeadMG have you filled out that language checklist?
3
 
lol
 
"[ ] The compiler crashes if you look at it funny"
 
6:37 PM
LOL
 
[ ] You require the language runtime to be present at compile-time ??
 
The best is: "[ ] You have reinvented PHP better, but that's still no justification"
 
@Pubby: Yeah, so it can use/link against the runtime. Turns out it's a much worse idea than it sounds.
 
[ ] You have reinvented PHP better, but that's still no justification
WINRAR
 
my company at work made their own programming language. It's great. The completion of an if block returns from the function, and if blocks cannot be nested. Also, no variable names. And all function parameters are variadic.
 
user142019
6:39 PM
@MooingDuck use C++ instead.
 
if you're gonna invent your own programming language
take my example and make it the best ever
 
user142019
@DeadMG that's impossible. Haskell is the best ever.
 
@WTP: It targets a proprietary bytecode as well.
 
I want a language like C++, but formats the source with haskell
 
6:41 PM
@Pubby: And JITted.
 
JIT stinky
 
lol
 
user142019
@Pubby and implemented in Malbolge.
 
user142019
(the JIT compiler)
 
I want "C++ with concepts but none of that C crap trailing behind".
 
6:42 PM
I'd love to see a JIT C++ runtime, just to wipe the smug grins off those java guys. I've heard that LLVM can do it, but that's just rumors.
 
user142019
@MooingDuck piece of cake.
 
I mean like statements could be defined by functions for {a b c} d =
 
@RMartinhoFernandes So in other words, WideC
 
@RMartinhoFernandes Isn't that D?
 
6:43 PM
D sucks
 
user142019
D sucks
 
lol.
 
S ducks
 
(Just to fit in)
 
user142019
6:43 PM
Lua rocks.
 
@robjb Lacks concepts.
 
Lua sucks
 
Lua sucks
 
user142019
No, it doesn't.
 
6:43 PM
yes, it does
 
I had to program in Lua for three years
it's terrible
 
PubbyGOGO rocks
 
user142019
Have you ever seen Perl?
 
user142019
6:44 PM
Perl
 
@Ell Compile it with -std=c++0x
 
I have supposedly heard of it's existence
 
@WTP That's not a good argument.
 
but I have never had the misfortune to have to use it
 
user142019
k
 
6:44 PM
lol, you can't make a case that something is good by demonstrating something that's worse
 
The fact that Perl exists doesn't make any other language good.
 
user142019
@DeadMG I had. :(
 
^
 
the fact that PERL sucks does not mean that Lua does not suck
it merely means that there are different degrees of suck
 
s/PERL sucks/Perl exists
 
Ell
6:45 PM
ruby wins
:D
 
user142019
Haskell wins.
4
 
WideC will win
 
lol, there was one kid in my program who wrote ruby.
 
Ell
i'm trying to learn haskell
 
6:45 PM
Everyone called him ruby Dave.
 
Ell
but its crazy
 
@DeadMG post some snippets so we can tear it apart?
 
Ell
dave is awesome
 
user142019
Who is Dave?
 
@Ell Don't diss Haskell!
 
6:46 PM
how am I supposed to do that? you can't tear apart a language that doesn't have an implementation
 
@Ell: I know of few languages (actually used) that are slower than Ruby.
 
@WTP A CS student who wrote ruby at every chance he got.
 
user142019
Haskell++.
 
more importantly, most of the details, I keep forgetting them
 
Ell
ruby is rediculously succint
 
6:46 PM
@DeadMG Sure you can. Some languages are bad starting from the design.
 
I know that I changed rvalue references, but I keep forgetting exactly what I changed them to
2
 
@DeadMG That's bad.
@DeadMG lol. You should write that down, you know.
 
nah
I'll remember when I come to actually use them
 
how much faster does SSE4 make most programs? I can't imagine it would make a huge impact...
 
Ell
mNodes[key] = mAllocator.construct(mAllocator.allocate(1));
error: void value not ignored as it ought to be
:/
 
6:47 PM
@Ell construct returns void.
 
Ell
hmm okay
 
user142019
Factorial in O(1).
 
You need to store the pointer beforehand.
 
still
 
user142019
very still
 
6:48 PM
the sooner I get over this fucking annoying compiler bug, again
 
I can get cracking
 
Ell
okay
 
user142019
Switch to another compiler.
 
@DeadMG Here's a nickel kid. Buy yourself a better compiler.
 
6:50 PM
I had some code yesterday that caused both MSVC11 and ideone to error out. That wasn't fun.
 
I'm writing a better compiler
 
user142019
A C++ compiler?
 
With a crappy compiler.
 
at least when my own compiler bugs out, I'll be able to debug it
 
Ell
right i've had a thought - if you write a compiler with bad, slow c++ code
can the code it compiles ever be faster than the code it was written in?
 
user142019
6:53 PM
Yes, it can.
 
user142019
Why not?
 
Look at GCC.
 
user142019
:p
 
user142019
GCC was written in C, wasn't it?
 
Ell
i dont know why not - just sometimes in my mind i get confused :O
 
6:54 PM
@WTP are we stating obvious facts now?
 
Ell
like when i start thinking about languages where all variables are references :s
 
ooooh
I think my free SO tshirt arrived
 
user142019
@Ell Take a look at the LLVM Kaleidoscope tutorial. The compiler's code is horrible, but the compiled code is very fast.
 
@Xeo Kobato of course!
 
Ell
oh kk
i just get confused sometimes :P
 
user142019
6:58 PM
somebody talk
 
why?
I have nothing to discuss because VISUAL STUDIO WON'T COMPILE MY FUCKING CODE
 
user142019
It's too quiet && try clang.
 
their exception handling is broken on x64
 
user142019
Try Haskell.
 
Visual Fucking Studio again
5
 
Ell
6:59 PM
i will talk :D
 
user142019
+1
 
Ell
i still dont understand why this allocator doesn't work
im compiling with
 

« first day (419 days earlier)      last day (4544 days later) »