« first day (420 days earlier)      last day (4530 days later) » 

12:00 PM
does MinGW include the standard windows C++ runtime headers? Like windows.h? etc
 
@TonyTheLion Yes
and windows.h is not C++.
 
Xeo
0
Q: Safe in C# not in C++, simple return of pointer / reference,

NiklasCode c++: person* NewPerson(void) { person p(); /* ... */ return &p; //return pointer to person. } Code C#: person NewPerson() { return new person(); //return reference to person. } If i understand this right, exemple in c++, its not ok because the 'p' vill go out of scope, and ...

~.~
 
Ell
windows.h is C, no?
and what is the name of the function that changed the type an allocator allocates? std::allocator<int>.rebase<string>()
?
 
::rebind. It's a member template, I think.
 
@DeadMG How's the parsing going?
 
12:02 PM
@Ell I suppose it's written in C, Don't know if there's anything ifdef __cplusplus in there (or in what it includes)
 
hmmm and what is crtdbg.h part of?
 
Ell
ahh rebind, thankyou
 
oh that's the c-runtime, guess MinGW doesn't have the C runtime...
 
@TonyTheLion MinGW-w64? :P
 
@ManofOneWay Work in progress
 
12:03 PM
@rubenvb no, don't think it's that one I have
 
@TonyTheLion if it's not in the MinGW headers, time to switch to MinGW-w64
 
@DeadMG You have also left-factored your grammar?
 
Xeo
@DeadMG *long work in progress, FTFY
 
lol
@ManofOneWay Doesn't matter, I've got left-recursive rules which are working just fine
 
@rubenvb that one will have it?
 
12:05 PM
@DeadMG It matters if you are using predictive parsing (which I hope you are using)
 
never seen that term before
 
Ell
nor have I?
 
Predictive parsing is LL(1).
 
predictive parsing or left-factoring?
 
@TonyTheLion I don't know how complete, but yes. Note MinGW(.org) and MinGW-w64 are not guaranteed ABI compatible. You can find my 32-bit toolchain build here: sourceforge.net/projects/mingw-w64/files/…
 
12:06 PM
LL(k) or LR(k) is predictive parsing, you predict by looking k tokens ahead
 
I do use it where necessary
 
And if you use it then the grammar must be left-factored
 
You have backtracking in places, don't you?
That makes it non-predictive.
 
uh
I don't think I do
 
what is good book to learn about parsers?
 
12:08 PM
Not even a little?
 
no
 
@Pubby "Books are for pussies" - DeadMG
 
the only place where I don't know for sure based on the current token, I used look-ahead
 
@DeadMG Can I see the grammar?
 
@Pubby People always mention the Dragon Book, but I have no idea if it's any good.
 
12:10 PM
the only grammar that exists is in my head
 
@ManofOneWay (There is no written grammar!)
 
I defined it once in Bison but that's not entirely up-to-date
 
For parsing the dragon book is good
 
Dragon book is the compiler one with dragon on cover?
 
Yes. Expensive as heck.
 
12:10 PM
the international version is cheaper
it's the same thing but without the dragon (and it's not hard cover)
 
How cheaper? 50€?
 
something like that
 
Ell
isnt it like £160 or something?
or $200 ?
 
Ell
oh kk
 
12:12 PM
I guess that's about 80 €.
 
Ell
or £60
 
the old dragon was cooler :(
 
Ell
teehee i have the stronger currency of everyone :D
 
12:13 PM
£40 from the UK store..
 
first edition is $40
 
577 Swedish kronor = 64.0594272 Euros
 
But it's paperback.
 
I got mine for 64€
 
I don't want a gigantic tome on paperback.
 
12:14 PM
Yes, does it matter?
 
Ell
get it for a kindle :P
 
When it comes to large tomes, yes, it matters.
That thing has 1000 pages.
 
It's not that big
The pages are also quite thin
 
Oh, I should add that I'm paranoid about creases.
 
Ell
is it bigger that c++ primer?
4th edition?
 
12:15 PM
No idea
 
If I get it a 1000-page book on paperback, it's bound to end up with creases on the spine.
That's not acceptable!
Books on my shelf must appear as if they were never read.
 
Xeo
Don't read them?
Easy solution :P
 
Not acceptable either.
 
Xeo
But I can understand the paranoia on creases
 
I can't lend books to my friends because they'll totally destroy them.
 
12:17 PM
I'll take a picture and compare it to Accelerated C++
is that fine?
where can you upload and share an image easily?
 
@ManofOneWay here :)
 
Ell
imgur
@manofoneway imgur
 
So Accelerated C++ is roughly 300pages, Modern Compi... 400 pages and Compiler 1009
 
Ell
c++ primer 4th is 884
imgur.com/0GYg5
 
how big is effective c++?
 
12:32 PM
297
 
Xeo
@cpx for lulz: The question is about C, there are no references in C :)
 
I think the idea of including a valediction at the front of the SO name isn't all bad, but it would require going through all old postings and fixing them, to to avoid double double occurrences.
 
Xeo
@AlfPSteinbach So you'd be known as "Cheers & hth. - Alf"? :P
 
Xeo
Would be strange to address you with @ notifications then, though
 
1:04 PM
@CheershthAlf.
 
Anyway we could discuss the cultural signals inherent in the designations of gender-specific organs. I think in English "pussy" that means "cat" which is a hunter, but also cozy animal that can snuggle up to you. While in Norwegian "mus" that means "mouse" which is prey, and not very social with humans...
Hm I'll go out and have dinner.
 
Xeo
hf
 
1
Q: A C++ Library similiar to C# .NET

heartofshivadoes anyone of you knows a C++ Library that has a similiar programming "style" like C#? Qt is very near to the .NET Api Style and far away of the Standard Template Library (STL) style. But I am searching something very easy to use like C# or Java.

 
@RMartinhoFernandes wasn't that what this young guy who was here last week was developing?
 
Xeo
1:11 PM
@RMartinhoFernandes What da fuck.
 
i think we need some basic classes: immutable string, stringbuffer, more versatile vector, so on. then their usage would be much like in languages like C# and Java. as i recall i got into deep conceptual trouble with how to implement common code for mutable and non-mutable vectors, it looked like jungle there...
 
Seems like @IDWMaster does have some potential users.
@AlfPSteinbach If it were me, first step towards it would be a handle class.
 
Xeo
@AlfPSteinbach What exactly do you mean with stringbuffer?
 
The .NET API does not play will with value semantics.
 
@RMartinhoFernandes yes, i found the intrusive shared pointer in boost really helpful. but one extra concept there, one eventually needs also that an object can keep reference to an object it is part of, to keep that outer object alive. like e.g. a substring in a string
@Xeo stringbuffer is the mutable class that complements immutable string. when you need to change things you do that in stringbuffer. then final result convert to immutable string.
 
1:15 PM
stringbuffer = buffed up std::stringstream?
 
Xeo
I still don't get what's so great about immutable strings
Also, our current std::string would then count as a stringbuffer, no?
 
me neither
 
well sort of but that was what i meant yes. only more practical. not weighted down by all that internal locale stuff. instead bring locale functionality and anything else to it, as needed. or not.
 
Immutability is a great way to make uniform reference semantics less confusing.
 
There's no reason why immutability is good for strings, though
if strings, why not List<char>?
or indeed, any List
 
1:17 PM
@Xeo they have about zero overhead. e.g. function returning immutable string from literal, can do that in constant time and no dynamic allocation. very efficient.
 
there's nothing special about strings
 
@DeadMG Immutability is good for those as well.
 
nah, that results in needless copies
 
hungry afk
 
@DeadMG Scala has excellent support for immutable data structures such as immutable lists and immutable sets.
 
Xeo
1:20 PM
@AlfPSteinbach That's the only inherent problems with our current std::string imho - no special handling for string literals, just because it's not possible to handle them specifically, because the language doesn't differ between "hi" and a char[3]
 
is there any operator that is always defined for classes?
 
@Pubby Sure, the assignment operator, the address-of operator, the comma operator...
 
But can those be deleted?
 
The assignment operator isn't always defined
 
@FredOverflow not if they're deleted, well, maybe not the address-of operator.
 
1:22 PM
Sure, you can delete them.
@Mankarse Right, only when it's used.
 
Xeo
@FredOverflow It's also not defined if you have const or & members
 
The assignment operator is only defined when you try to use it. If it then turns out your class has members that don't support assignment, the compiler will barf.
Does the default allocator use operator new?
 
Note: A container calls allocator_traits<A>::construct(m, p, args) to construct an element at p using args. The default construct in std::allocator will call ::new((void*)p) T(args), but specialized allocators may choose a different definition. —end note
so I would say yes.
 
1:51 PM
@DeadMG Could you by any change write your grammar down? It would be a nice exercise for me to compute FIRST and FOLLOW sets and the final parsing table
 
Ell
hi guys - is there any way to use a typedef to allow a default type parameter for a template?
eg. NoDefaults<typename T1, typename T2>
typedef NoDefaults<typename T1, typename T1> Defaults<typename T1, typename T2 = double>
i cant get it to work :/
 
typedefs can't be templated
use c++11 using
 
Ell
are you sure they cant?
 
template<typename T1, typename T2 = double> using defaults = nodefaults<T1, T2>;
 
Ell
2:01 PM
okay thankyou! :)
 
Why does the std still use typedef?
using break compatibility or something?
 
Ell
hmmm
what is wrong with this defenition
template <typename MapKeyType, typename MapValueType, typename Allocator = std::allocator<Item<MapKeyType, MapValueType>>> using Map = CustomAllocMap<MapKeyType, MapValueType, allocator>;
where item is
template <typename ItemKeyType, typename ItemValueType> class Item;
customallocmap is
 
you didn't capitalize allocator
 
Ell
template <typename MapKeyType, typename MapValueType, typename ItemAllocator> class CustomAllocMap
grrrr typ
*typo
but still - i get expected unqualified-id before "using" - i guess my compiler doesn't support?
 
what compiler?
 
Ell
2:07 PM
eerrm lemme check: i think its 4.6.1
yeah 4.6.1
 
it was added in 4.7
 
Ell
okay
 
the feature is template aliases
Clang has them
 
upgrade to 4.7?
 
@Pubby 4.7 isn't done yet
 
2:09 PM
unstable is pretty stable
 
Ell
aww gee thats annoying
 
Switch... to ... Clang!
if you're not on Windows :)
 
Ell
im on ubuntu :)
 
switch to Clang! But you'll need 3.0, not sure if they have it in the repo's
 
Xeo
@Pubby We sure don't know.
 
Ell
2:13 PM
naaah im giving up c++ after this incident
 
Xeo
I even wondered why all that <type_traits> stuff is structs rather than convenient usings
 
@Xeo ??
 
@Xeo two words: function objects
 
Xeo
@rubenvb ?
 
void foo(int a[1234]) is the same as void foo(int* a) right?
or is that just with a[]?
 
Xeo
2:24 PM
It's the same
 
same
 
Note, however, that f(int a[12][34]); is not the same as f(int** a);.
 
@FredOverflow What does it do? (wasn't there a question on this a few days ago?)
 
The first declares a function of type f(int(*a)[34]);, and that parameter type is not same as an int**.
 
so a pointer to an array type?
 
2:31 PM
right
A pointer to the first "line" of the 2D array, if you will.
 
multidimensional arrays are confusing
[x,y] seems like it would make more sense
 
They become a lot less confusing if you use std::array<T, N> instead of T[N].
@Pubby [x,y] is interpreted as [y] because of the way the comma operator works.
 
what exactly does the comma operator do?
other than int x, y; kind of stuff
 
It evaluates its first argument, throws it away, and then evaluates the second argument.
There is no comma operator in int x, y;
 
what's the use of it?
 
2:34 PM
The ++i, --j part to update two for loop counters is a popular example.
 
makes sense
 
It evaluates operands and returns the last of it.
 
Also while (c = getchar(), c >= '0' && c <= '9').
 
why can you overload it?
 
Boost.Assign is a nice example for overloading the comma operator.
 
2:35 PM
Why not?
Address-of can be overloaded, too, even if it's of limited use.
 
it causes us to need a address of function
and to use void() or whatever
 
Er, no, you typically never overload address-of.
 
I think Microsoft COM overloads & somewhere.
 
@FredOverflow You're thinking of the ATL library. It did at first, then provided a workaround thingy.
 
What is the ATL good for?
 
2:39 PM
How does this work? `vector<int> v;
v += 1,2,3,4,5,6,7,8,9;` I thought built-in types couldn't be overloaded
 
vector isn't built-in.
 
Very light weight. Gives you window framework and COM support all in one. But has some grotesque Microsoft practices embedded.
 
Oh, so += is evaluated first, then the comma
 
You create type_with_comma_overloaded operator+=(vector<T>, T)
 
@Pubby Note that += has higher precedence than ,
 
2:40 PM
Also it's foundation of WTL, which was the Microsoft in-house windowing framework, now at sourceforge i think
 
cpx
In function call args, f(i, j); is not comma.
 
Well, it's a comma, but it's not the comma operator :)
 
See also: Boost.Assign.
 
cpx
More examples D() : BaseA(), BaseB() and for (int i = 0; i < 42; i++, j++)
 
@cpx The first is not the comma operator, the second one is.
 
2:41 PM
I sometimes write assert(("blah", condition)). Andrei thought that was silly, one should write assert( "blah" && condition ). I don't know, I don't find that latter natural.
 
Nvm..
It's ctor init list, derp.
 
@CatPlusPlus Nvm? Is that a virtual machine? ;)
 
Xeo
@FredOverflow non-virtual machine :P
 
Yeah, it kicks in when your brain shuts down.
 
Xeo
Oooh, "neural virtual machine"
 
2:43 PM
@cpx What makes you think i++, j++ is not the comma operator?
 
for ( for-init-statement condition(opt); expression(opt)) statement
 
Is this ever valid: ,,?
 
It can't not be comma operator.
 
@Xeo actually that's the thing i'm waiting for. after Scott Fahlman identified virtual copies as the basic tool in semantic networks, nothing's happened. for about 40 years now. it's scary. there's development in almost every other area than AI.
 
cpx
hmm
 
2:45 PM
@Pubby No.
 
i'm waiting for the Cool Guys, those who make that robot dog etc., to pick up on Scott's idea.
 
cpx
@FredOverflow In for loop or just i++, j++?
 
@cpx Doesn't matter, anywhere.
 
@FredOverflow Not anywhere!
f(i++, j++);
 
I meant as an expression :)
 
2:47 PM
It's like, when you read a detective novel, in your mind you're creating a virtual copy of ALL you know about reality. So that reasoning about things in the novel you can apply knowledge about e.g. usual behavior of cats, or whatever. You're just inheriting all that stuff from the real world model, with the book's drama as a slightly modified virtual copy.
 
Is that a quote?
 
And then the book screws you and changes the rules midway.
Well, bad books at least.
And lots of movies.
 
Also programming languages? ;)
 
@FredOverflow Scott-man also invented the smiley. According to Wikipedia.
 
@AlfPSteinbach Scott-man?
 
2:53 PM
Quiz time! Where is ,, valid syntax?? @CatPlusPlus I found a way
 
other than macros
or comments
 
Comments.
 
Congratulations. You've now wasted half an hour of your life.
 
String literals.
 
2:53 PM
I refuse to play against shifting sand anymore.
 
:(
&foo::operator,,0;
 
You can pick up any part of C++ and come up with an obscure use case to make a puzzle. Just look at litb.
 
Wouldn't it work with this: Foo & operator,() { return *this; }
 
// ,,
I'm setting down new rules here: if you want to set up a quiz on this room, you must specify all limitations that make your solution the only one.
 
@StackedCrooked must take a parameter
 
2:55 PM
@Pubby Oops, I forgot that.
 
// limitations: no matter what you may come up with, my solution is the only one!
 
It's like a detective novel. It sucks if the reader is never given enough information to solve the case on its own.
 
Could this work?: Foo & operator,(const Foo & foo = Foo()) { return *this; }
Probably not.
 
@DeadMG In your parser, will you go from tokens to an AST? Or Tokens to some other tree to some AST?
 
can't have defaults in operators
@StackedCrooked I already posted the solution. I think it's the only one
 
2:59 PM
Don't spoil my fun.
 
your fun is spoilt
 

« first day (420 days earlier)      last day (4530 days later) »