« first day (277 days earlier)      last day (4674 days later) » 

6:00 PM
I wrote a little generic function memoizer: ideone.com/arp14
 
I already don't trust your hash_combine.
By the way, std::unary_function and the like are deprecated. They're not needed anymore!
 
My hash_combine, dear sir, is lifted directly from boost!
Oh, I didn't know -- can I get rid of all those old functional base classes everywhere then?
 
Also this would be a perfect use for my indices<Indices> stuff to unpack the tuple!
@KerrekSB I don't use them anymore and don't feel any pain.
Still it's a valid question: is there no utility that comes with std::hash to help?
 
Say again?
 
again?
What do I win?
 
6:05 PM
(Can you link your Indices/future ideone again? I didn't save it, alas.)
@CatPlusPlus Shush :-)
@LucDanton I did not understand that question.
 
My mind is blown: there is now a std::type_index type in the Standard library.
Everytime I open the FDIS I'm surprised.
 
Err... what does that do?
 
BTW, that composition thingy was useful, or not really?
 
@KerrekSB My mind is not fully awake ATM. I meant to say that it's surprising there aren't helpers provided along std::hash to do what you're doing.
 
6:07 PM
Or maybe it was a different person, nevermind. :P
 
I'm extremely surprised, too, given that it's all in Boost (functional_hash.hpp).
 
What was (sometimes) done before std::type_index: struct type_index { std::type_info const* p };
 
Boosts hashes everything: ranges, containers, sandwiches...
 
Half of the new stdlib stuff was in Boost before. :P
 
Anyway, I'm finding it very useful to pull hash_combine and the pair- and tuple-hashers into my code so I can use unordered containers at will.
@CatPlusPlus Yeah, I hope even more will make it into TR2! Hashing, zip iterators, bimaps...
 
6:09 PM
Oh wait, I just switched from n3242 to FDIS. Perhaps it's a late addition. (Nope it's in n3242 too.)
 
@Luc: do you still have your old ideone link?
 
I think they'd like to push entire Boost.Iterator into standard.
 
Yeah, that'd be cool
(Also, where can one get the FDIS?)
 
I huh really have no idea. I found mine on a road. Must have fallen from a truck.
 
Isn't 3290 newer?
Ah, I'm misreading, as usual.
I'll just go over there.
 
6:12 PM
I thought 3290 is the FDIS.
 
It is.
Did you know you can't offer milk as a prize in Facebook contests?
 
Curious. Why not, though? :-)
If either of you are bored, do you have an opinion why in this test the manual copy+swap and move+swap is far more inefficient than the compiler-generated one? (-DROLLOWN)
 
What's the point of a swap that binds to rvalues?
 
@LucDanton Nice.
Err... OK, I was pretty much not sure how to correctly implement assignment-via-constructor+swap
 
Just like you do but no need for std::move.
swapping really is for lvalues : int a = 0, b = 1; std::swap(a, b);
After that a, b must really be usable, they won't be in the canonical 'usable but unspecified state' of a move.
 
6:18 PM
Oh, of course
 
So swap is an algorithm that takes two lvalues and has the two lvalues valid as a post-condition.
 
Indeed, with move removed, I get almost identical compilates.
Yes
 
you can swap rvalues
 
It's a mixed signature though isn't it?
 
@DeadMG What's the typical use case?
 
6:19 PM
it's of dubious value, of course, but one of the ways to shrink a vector before shrink_to_fit was introduced was vector.swap(std::vector<T>());
 
(T&&, T&) would make sense but (T&&, T&&) doesn't seem useful.
 
Especially since I want the most efficient assignment operator by value
 
Then use the compiler generated one imo.
 
(So that the value can be both copy and move constructed, depending on what's available.)
 
@Luc: You would use T&&, T&& so that you can forward
 
6:20 PM
It's much more likely that some knowledgeable people will tun the compiler to do the right thing.
@DeadMG Forward to what?
 
if you do T&&, T&, then I hope that you didn't want to swap an lvalue and an rvalue, instead of the other way around
 
Yeah, I just want to understand how to do it right, in case I need to... or is it always best to never write any operators at all and just use the correct smart container members?
 
template<typename T, typename U> void swap(T&& lhs, U&& rhs) {
    T temp = std::move<T>(lhs);
    lhs = std::move(rhs);
    rhs = std::move(temp);
}
always? no
 
If you use std::forward
Wait what.
That's horrible.
 
if you're writing a resource-managing class, then you have to write your own operators
 
6:22 PM
@DeadMG Single responsibility principle: Make the right class for the job.
 
That's the point of forward in there.
 
yeah, I might have forwarded when I meant to move
 
OK, fine, so I do have to write the lowest-level class myself. Yes.
 
Exactly.
 
the point is the same, though
the arguments are both rvalue references to enable perfect forwarding
 
6:23 PM
Really, that swap function has to be three lines? Hmm...
 
plus why allow swap(T&&, T&) (not using perfect forwarding, assume T&& is an rvalue ref) when the client code could just as well use rhs = std::move(lhs);? What does swap(std::move(lhs), rhs); buy exactly?
Brb.
 
Well, when you're implementing the assignment constructor...
 
@KerrekSB That doesn't change anything!
 
6:45 PM
If I'm implementing A::operator=(A&& other), then I can't just have *this = std::move(other); in the body, can I?
(or rather A::operator=(A other))
 
Yes.
That doesn't mean you should write swap(std::move(*this), ...) either.
 
Hm. Why can't I take advantage of the fact that I'm not going to need *this again?
 
Do you think of ever writing std::move(lhs) = rhs?
When you assign, something simply gets written upon.
 
Yeah.
 
The real magic happens with the pass-by-value anyway!
 
6:51 PM
I finally solved my puzzle :)
 
By the way, in the memoizer, how can I use the indices helper to make the tuple hasher more compact? I will have to call hash_combine for every element of the tuple, so I don't see how I can avoid a recursive definition of the hasher.
I can't just write hash(args...) (without making the hash function itself recursive).
@LucDanton Yes, that's true. That's really elegant.
 
I would have used a variadic function instead of a struct specialization.
But you're right it's not a clear win.
It just happens that I already have the indices stuff and I don't mind writing recursive functions.
 
I see. Yeah, that could have been done, but since I just lifted the hash_combine from Boost I didn't want to fiddle with it, hoping that it'd be in the standard one day.
 
Oh! right.
That thing really irked me, what with using an out parameter.
I notice type_info now has a hash_code() member.
 
yeah, you can finally associate types to something
 
6:59 PM
@Kerrek By the way, is there documentation for boost::hash and that combiner?
I'm curious as to how much the combiner is preferable to xor-ing.
 
@LucDanton ;)
 
@MartinhoFernandes Figured out what was happening this morning: the executable that segfaulted was not the one being debugged.
 
Huh.
I have no words.
 
@LucDanton Just XORing would be terrible, consider that integral types are just hashed by the identity.
 
@KerrekSB I found the boost docs.
 
7:03 PM
(3,5,3) and (3,3,5) would hash to the same thing
 
Welp, that boost::hash_combine is handy.
 
Where??
 
Does (multiple) non-virtual inheritance add runtime overhead? (Or: does policy-based class design come with a cost?)
 
I don't think so.
 
Dynamic dispatch has a cost.
That's not what you mean is it?
struct derived: virtual base, virtual other_base {}; multiple virtual inheritance
struct derived: base, other_base {}; multiple inheritance without dynamic dispatch
Which are you asking about?
 
7:16 PM
@LucDanton I wonder about non-virtual interitance (the second). This SO post seems to answer my question though: stackoverflow.com/questions/1279290/…
 
> Overhead of C++ inheritance with no virtual functions
Second one then.
Silly C++ and its overloading of keywords.
 
Hmm, just learned that a lower bound on complexity for matrix multiplication is an unsolved problem in CS.
 
I suggested policy-based design for a mutex class to a colleage of mine. He responded that he wanted to avoid the overhead. I made the claim that there is no overhead if the base classes have no virtual methods. But just wanted to be sure..
 
Is there any other term than virtual to mean 'single base in a multiple inheritance scenario'?
 
@LucDanton I see, you had a typo. So we're on the same page now concerning hash_combine?
 
7:19 PM
@KerrekSB Yes.
 
@LucDanton yeah, I now realize that my question was worded wrongly (I meant without virtual methods, not virtual inheritance.)
 
5
A: Partial Specialization of tuple contents with variadic arguments

James McNellisIf you compile using clang, it helpfully reports that (2) and (3) are unusable. The warning for (3), which you expect to be selected, is as follows: warning: class template partial specialization contains a template parameter that can not be deduced; this partial specialization will never ...

please verify comments
 
@JohannesSchaublitb I get that you're saying that not all pack expansions are required to occur as the last parameter, but are you also saying that what the OP is doing is allowed?
 
Args cannot be deduced
like clang says
 
Oh, so you're replying to the previous comments?
> I don't think that " If an argument is a pack expansion, it shall be the last argument in the template argument list." applies here.
(I'm asking all this because I'm too slow to figure it out myself.)
 
7:24 PM
@DeadMG vector.swap(std::vector<T>()); does not compile, the swap member function expects an lvalue. You probably meant std::vector<T>().swap(vector);
 
my testcase crashes GCC and it says "main1.cpp:2:306: internal compiler error: in unify, at cp/pt.c:15729".
15k lines in one file!
 
after preprocessing, maybe?
 
@FredOverflow An lvalue such as std::vector<T> vector; was meant I assume.
@JohannesSchaublitb I think I got the gist of it and I agree, the Standard quote doesn't seem like the right one.
 
@LucDanton lvalue.swap(rvalue); does not work, but rvalue.swap(lvalue); does.
 
7:30 PM
So it does.
 
0
Q: what does a expression like arr[''hi there"] imply?

sunif a=3 and b=2 what does this imply printf(&a["Ya!Hello! how is this? %s\n"], &b["junk/super"]); arr[4] means *(arr+4) so i need to know what does a expression like "hi there" imply?

if there was a WTF section of SO, this would be one of them.
 
Half of the SO is a WTF section.
 
@CatPlusPlus If some us weren't so dedicated, the questions would get closed quickly rather than try to decipher what the person is trying to ask
 
I'm hoping that's a demo to demo associative nature of []
Otherwise, please leave code alone.
 
@Xaade OP changed it again
 
7:41 PM
Someone upvote my comment.
 
@Xaade I did. I tried making a and b integers, but he changed it back
 
I'm not sure it was on purpose, what happens in case of an edit collision? Unless he really cares to spell 'I' as 'i'.
 
Unless they changed something, SO happily disregards the fact that there might be several people editing, and just saves the content as it comes.
 
Just call it a 'distributed concurrent comment system' and it's a feature.
 
yeah
there should be some kind of 'edit lock' in a post
 
7:47 PM
Optimistic multithreading, eh.
Lock, or a conflict resolution system.
 
let's put all SO content in version control
 
When you save something, but someone edited in the meantime, you get thrown back to the editing.
Wikis and alikes are supposed to be version control. SO just fails at conflicts.
Utterly.
 
but we're experts, we never disagree with each other
 
@JohannesSchaublitb Are real world compilers really that ugly? :( Couldn't they write a C++ compiler in Haskell or something? :)
 
7:56 PM
Could win $50,000
 
8:10 PM
@MartinhoFernandes Glad you like my TMP solution :)
 
ok
I already built a lexer once, but I'm sitting staring at my empty lexing algorithm
 
Basically, you implement a finite state machine.
 
I've never explicitly created a state machine
never found a need for one
 
the theory is boring
just go ahead and write dirty code. somehow it will end up working
 
8:19 PM
ok
I lexed some comments
that wasn't too difficult
 
the cool kids just use flex
 
yeah, if you have a version newer than 1997 that runs on your platform
 
Of course the cool kids have such a version.
 
@JohannesSchaublitb What happened to "just go ahead and write dirty code"?
 
@MartinhoFernandes You use the cool kid's tool to generate it.
 
8:22 PM
woot it scrolled up my screen
 
What's the latest version? 2.5.35?
 
what should have happened to it?
 
@MartinhoFernandes I don't have it installed right (looks like I'm not cool enough), can't check.
 
I managed to be cool enough to check what's available:
> Version: 2.5.35-10
 
8:25 PM
@MartinhoFernandes oh i see what you mean.
i consider flex dirty code xD
 
2.5.35 runs on Windows, it just needs Cygwin.
You're all talking about lexing and parsing and you've motivated me to get something done.
I'll probably won't anyway, but the thought counts, right?
 
That's the spirit!
 
go go Cat
 
Spirit is scary.
 
you know
my puppy has been running around my living room forever attempting to catch a fly
 
8:29 PM
But I'm not doing anything fancy, only trying to make a data file parser better than what's in libtcod.
The default is meh and pretty much restricted to on-disk files.
 
what else would you do with a file parser except parse on-disk files?
 
It's a terrible limitation. I'd be more happy if it were limited to in-memory strings.
I want to load mods straight from the archive at some point, there is no on-disk file to parse, only a virtual one.
 
oh, you mean it doesn't take a generic input stream?
 
Yeah.
 
that sucks balls
 
8:32 PM
A filename in the APIs and stdio inside.
Even in the C++ wrapper.
 
C++'s cout can be re-directed
although if in the C++ wrapper it still just does fscanf(stdin, ...), etc
 
My plan is make the parsing core in flex/bison, and then generate the higher level parser from the schema.
It doesn't use cout, why would it use cout? :P
 
I guess you called it a wrapper, not an actual implementation
 
Writing a roguelike?
 
All for GC.
 
8:36 PM
GC?
 
man
I love the new VS2010 feature where you can select multiple text lines to work on
 
I have roguelike in TODO, but I'll probably never get to it.
 
so useful when doing repetitive code
 
Goblin Camp, what else.
Currently parsing looks like this.
Heh, empty reentrant lexer is 55kB. Generating code is awesome.
 
what's Goblin Camp
 
8:41 PM
An awesome open-source game.
 
I see
 
@CatPlusPlus It's an ASCII-art strategy game ?
 
looks like DF
you the creator?
 
No, just contributor.
 
8:43 PM
@DeadMG it is a spin-off of DF, more or less. Some guy didn't like the direction DF was going in
 
@kbok We have graphical tilesets, too.
 
awwww, fuck
 
The deeply nested templates in Boost make the most incomprehensible error messages: http://t.co/qduh9SG
 
I want to overload a lambda
 
Spirit is scary.
 
8:44 PM
lol
 
@CatPlusPlus The more I get warnings like that with GCC, the more I understand where I made a mistake. It's weird.
 
you know
I had a sweet idea for lambdas
if you define them in a loop, you could break or continue from within the loop
maybe
 
I know some languages that do this and what displeases me is that it's never explained what I should do if e.g. I have a loop in the lambda and I want to break from it.
IIRC some languages have two kinds of lambda to solve this problem, where the ones that can break from an enclosing loop aren't first class and can't do all the stuff of the regular kind of lambdas.
I don't know what the other languages use; some kind of keyword(s) expression such as return continue; would work I guess.
Looks like a coroutine tbh.
Why not have that instead.
 
They were planning on doing that for Java 7.
Non local returns.
A lambda could return for the function containing it.
And then they just ditched lambdas because they're not "OO enough" or something.
 
I like that the name is honest with what it does. When I read 'non-local return' I'm instantly distrustful.
 
8:59 PM
Java planned to have lambdas? OMG.
What about the poor interfaces and anonymous classes? It's so reusable and OOP and shit!
 
Supposedly, it was the big feature of Java 7.
 
The biggest feature of Java 7 was not sucking. They failed to achieve that.
 
They have experience in that.
 
9:15 PM
- fixed Defect from DR7290
- fixed Defect from DR4211
- implementations are not required to emit a diagnostic anymore regarding issue #3398
- the language does not suck anymore
Like so?
 
9:35 PM
GG
 
never mind
you know, lexing is going to get old pretty quick, lexing all these operators and assign equivalents
if only I could continue from within a lambda
 
@DeadMG I don't know what you mean with GG?
 
it's "Good Game", which basically means "You Lose".
alternatively, it also means "I lose", but it's usually obvious from the context
there's more subtlety to it than that but that's the basic
also
lambda functions, they rock so hard, it's amazing
 
I need a hug
 
9:49 PM
/hug Chet
 
lol ty @DeadMG
 
hey, I'm well familiar with that feeling
 
looks like I'm going kernel mode in an exercise in futility
 
what are you trying to accomplish?
 
sending dll load events to the debugger
 
9:54 PM
did you compile the DLL?
even if you didn't, you could hook the LoadLibrary call
 
yes. but I'm not using LoadLibrary() to map it into memory
 
custom loader?
 
yes. supports several shared library formats including a couple that are proprietary
 
This sounds scary.
 
most of it's fairly simple actually
but at least by going kernel mode to handle the debugger I can add support to include it in the module directory of the process as well
or at least have a chance of including it lol
bbiaf
 
10:05 PM
bbiaf?
 
Does anybody know if there's a term for the nodes in a tree that are direct parents of the leaf nodes?
Saying just "internal nodes" is too strong.
 
@DeadMG bbiaf = be back in a few
 
@Chet: Ok
@GMan: No idea, what's wrong with just leaf parent? :P
 
@GMan asexual node?
 
@GMan Stem node.
 
10:16 PM
@ChetSimpson lol :P
 
@DeadMG Nothing, just wondering.
@JerryCoffin Sounds good, but I can't seem to find wide usage of it online, but I'll use it anyway.
 
just make sure you pull the all stems out before you smoke it
 
by the way
I love lambdas
make it so easy to re-use my token detection logic
 
10:56 PM
@GMan You're now officially a trendsetter.
 
11:09 PM
That's odd... I wrote (failed_at = Names, table[Names]) (where table[Names] can throw) and GCC pointed out to me that the results were unspecified, which I'm inclined to believe.
So I changed it to table[failed_at = Names] and I still get the warning.
Since this is a user-defined operator[] I would have thought the assignment would be sequenced before entering the function, and thus the potential throw. So false positive or not?
 
false positive
you're absolutely right that entering a user-defined function introduces a sequence point and that the assignment is well defined to execute before the operator[]
 
The warnings I get aren't nice at all given that this happens in a specialization that resides deep inside the bowels of luabind...
I'm not sure how to get this right(er) since it's a variadic pack expansion :(.
 
honestly? I'd post a more detailed question to SO
turning off warnings is probably a bad thing
 
Minimal test case to the rescue!
This is proving harder to reproduce that I would have thought...
 
11:27 PM
as it always is
 
How subtle...
The pack expansion is happening inside a braced-list-init.
When the type that is being constructed has a std::initializer_list constructor, GCC doesn't complain.
If on the other hand it doesn't (i.e. in my code it's an std::tuple so variadic constructor), it gets flagged.
And now to double-check the Standard.
Okay so my guess is that's it's not a false positive, but that GCC doesn't implement the braced-list-init correctly. They're required to evaluate the subexpressions in order (which I was relying on in the first place), but possibly GCC only honor it when it comes to constructing an std::initializer_list, and not when making a constructor call.
Works for aggregate initialization too.
 
11:43 PM
the important thing is that I solved your problem
because I'm a C++ expert
 
Did you? Are you?
 
:P
 
Btw what problem is solved? I can still see the warnings right now :p
 
well, you know what's going on, you can submit a bug report
and either turn the warnings off or address the problem some other way
 
I'm going to 'manually' throw on the line before that construction and not check in the braced init list. That way I can already use the exception catching code.
Also previous bug report has yet to be assessed. I don't think this is not already known, either.
 
11:48 PM
well
my lexer clocks in at 400 LoC right now
that's pretty small, the autogenerated lexers I've seen were massive
 
You're hand-writing it?
 
yep
I was deeply dissatisfied with the quality of generated lexing code
like, horrific C interfaces, etc etc
my custom lexer is definitely thread-safe, definitely RAII-enabled, etc
 

« first day (277 days earlier)      last day (4674 days later) »