« first day (1064 days earlier)      last day (3898 days later) » 

6:00 PM
@KonradRudolph The real problem here is people wanting to use enumerations as flag sets, which they are not.
 
i usually use enumerators as flag names
and unsigned as the flag set
 
Ell
std::set<Flag> is better?
 
@DeadMG Not sure I understand. This is an established idiom (e.g. set_font(style::bold | style::italic) – what do you suggest?
Of course std::set is better in general, but the performance loss is entirely unacceptable for some situations
 
Ell
Right
 
how is std::set better to use
isn't it more complex
 
6:02 PM
@KonradRudolph I'm not saying that it's not the best achievable. I'm saying that enums are a shitty hack when you really want a set of flags.
 
That said, I’m pretty sure that we could specialise a set class (not std::set) to make this efficient – as in, overhead free
@DeadMG Yes, agreed then.
 
Ell
@KonradRudolph why not std::set?
 
enums are a perfectly fine way to declare a set of flag constants
 
@Ell Because I’m not sure specialising standard containers is legal, and also its syntactic support isn’t great
 
Ell
Oh right okay
Meh. I'm stuck on design :3
 
6:05 PM
alright, dinner preparations
 
be sure to not use non-range for for it
 
Ell
I want to separate drawing code from game logic code. I was thinking of having for example a Terrain and TerrainDrawer class. But that just seems too java
 
6:33 PM
Cookie Clicker gets more and more addicting every day. I'm nearly at 1 quadrillion cookies.
 
6:45 PM
@KonradRudolph Achievement unlocked: Quick removal
 
wouldn’t onebox
success
Made only from range-based for loops, @JohannesSchaub-litb
… or free-range for loops? I’m getting confused
 
@KonradRudolph Have you tried with a compiler? typename std::enable_if<is_flag<T>::value>::type... is wrong I would think.
 
@LucDanton Tried, works
Anyway, isn’t that the moral equivalent of wheels::EnableIf<…>...?
 
@KonradRudolph That looks tasty :3 what is it?
 
pan-fried salmon with vegetables in lemon butter sauce
 
6:49 PM
ok now im hungry xD
 
@KonradRudolph No.
 
@LucDanton Damn, why not? Doesn’t the latter also expand to a type? Does it matter that that’s an enum class type?
(answering my own question: yes. duh.)
 
Can't have void non-type parameters.
 
makes sense. Question is, why does GCC 4.8 accept it?
 
@KonradRudolph because it SFINAE fails
 
6:53 PM
Whichever version of clang is on coliru also accepts it.
@JohannesSchaub-litb What is called instead?
 
@JohannesSchaub-litb Then it wouldn’t compile. Remove the code => doesn’t compile any more
 
wait
you have declared a pack. you haven't expanded anything
 
it fails exactly for types for which is_flag is false_type (or undefined).
 
i wonder wheter there are any rules for the type of a non-type parameter pack
 
6:56 PM
main.cpp:7:78: error: a non-type template parameter cannot have type 'void'

template <typename T, typename enable_if<is_flag<T>::value>::type..., void...>
 
or whether they just inherit the rules of te non-pack case, once they are expanded
 
Certainly seems funky.
 
@LucDanton Where do you get this error?
 
@KonradRudolph Just checking what happens if I manually insert a void... pack.
 
6:57 PM
@LucDanton i think that this may be related to llvm.org/bugs/show_bug.cgi?id=11723
 
@JohannesSchaub-litb And GCC bugging on its own as well? Color me skeptical.
 
@LucDanton yeah weird
 
I’ll leave you guys to figure it out, I have to clean the dishes and go buy ale
 
but then there are other C++11 rules not implemented by either compiler
 
The thing is, I'm fairly sure that I've settled on enum class enabled {}; template<typename Cond> using EnableIf = typename std::enable_if<Cond::value, enabled>::type; for a reason, i.e. that would mean a regression on GCC's part.
 
7:01 PM
@LucDanton perhaps they are first deducing the length, and then they are substituting
 
Because the enabled dummy type has no other purpose than being a non-type parameter type. If I could have picked void, I would have.
Or maybe the fact that it's supported now is an improvement, and whichever rules allow for a (deduced computed) void non-type parameter are not obvious to me.
 
so they first get <T> (or <T, foo<T>::type>, if you have a second template argument), and then substitute T
a trailing parameter pack that was not otherwise deduced is deduced as being empty
 
Fuck this shit. I'm using cheat codes.
 
@LucDanton but this means that I don't think it will work at all. it will never be SFINAEd out
 
Generics is so damn ugly in C++ and C#
They could learn a thing or two from haskell
 
7:04 PM
@GamesBrainiac Except that C++ and Haskell do not actually have generics, sure.
 
@GamesBrainiac generics in C++? wut...
 
@JohannesSchaub-litb I'll plug in void in my EnableIf alias and see what happens!
 
Also, you're a bit late for the "I just discovered haskell and therefore I think it's the best thing ever" thing. That was last year.
4
 
Don't compare C++ TMP to C# generics
@jalf or this year if you're Bartek :P
 
@Borgleader ... or else!
 
7:05 PM
@jalf Shit sorry. Wrong word. I was talking about this -> [a] -> a
Where you define a function
 
wat
 
Polymorphic functions
Thats what I was getting at
And what? C++ does have generics.
Its got templates. Even a guy as dumb as me knows that
 
@GamesBrainiac C++ has templates. C# has generics
 
@jalf Whats the difference?
 
TMP is much much more than generics.
 
7:06 PM
More often than not generic programming will make use of the type and data families extensions. Guess what that looks like in C++?
 
Templates can be used to do generic programming, but templates are not generics
 
@jalf Define generic programming and generics
Because I've always thought they were the same
 
@GamesBrainiac Well, they're fundamentally different language features, implemented in different ways and with different capabilities, but they happen to use nearly the same syntax a few operations which behave similarly in the two languages
 
@jalf So in practice they're the same right.
 
@GamesBrainiac no
 
7:08 PM
@GamesBrainiac no
 
@jalf Define different capabilities with examples in both languages
All you need a template for is to stick in a type you don't know, or you don't want to write overloads over and over again
Same with generics no?
 
That's extremely basic template usage.
 
Templates are what the name implies. Templates, used by the compiler at compile-time to "stamp out" new functions or classes, which are then nothing more than regular functions or classes (with longer, messier mangled names). vector<int> and vector<float> are fundamentally different classes
 
@JohannesSchaub-litb It breaks all sorts of things.
 
But C# List<int> and List<float> are just the same generic class, with a different type bound to it
 
7:10 PM
@jalf So, we're talking simple code generation
 
@GamesBrainiac For templates? Yes, pretty much, actually
Templates are processed at compile-time, generics are not
 
@jalf That makes perfect sense.
 
Also, templates can be specialized (see vector<bool>, which does not behave like a vector of anything else)
 
This part nailed it -> generic class, with a different type bound to it
 
7:11 PM
whereas generics are really nothing more than "list of T", or "a function which takes U and return V"
 
@jalf Thanks for that. I've always assumed they were the same, since in practice I did not find them to be different.
 
whereas templates are turing-complete so you can do all sorts of crazy shit with them :p
 
@jalf So, ideally, Templates are more powerful than generics in C#?
 
but yeah, they have similar syntax for a simple stuff like "list of T"
 
dammit. it changed the code
 
7:13 PM
@GamesBrainiac Not sure what you mean by ideally, but yes, they are
whereas generics are a lot simpler to understand and use and reason about. And do not hurt compilation time as much. ;)
 
@jalf No, that seems to be your sales pitch. So, give me an example of what you could do with templates that you cannot do with generics in C#?
 
@LucDanton ideone.com/9cgCFT
and when you pass something to it, then it notes the "void"
 
@GamesBrainiac I already did. You can implement horrendous evil stuff such as std::vector<bool>, taking a perfectly innocent and useful class template, and making it do something completely different if you pass in the right type. ;)
 
@jalf All you're doing is creating a vector list of booleans.
 
@JohannesSchaub-litb I can't really nail down why it doesn't behave that way every time though (i.e. why some of my code breaks).
 
7:15 PM
@GamesBrainiac no
 
@jalf Then what are you doing? And how is it evil, thats where the fun stuff is right?
 
@LucDanton weird
 
All it does is create a dynamically sized bitfield, and instead of letting you access each member directly (which you can't do, because they're stored as bits, not bools), it returns proxy objects of some wierd unspecified type
... and as a result of its "special" behavior, it does not actually satisfy the requirements for a container according to the standard. Yay.
 
The standard committee decided to do an "experiment" with std::vector<bool> and it's a bitfield. There's a section in Effective C++ (or More Effective C++) on this.
 
@jalf So you could do some fun binary addition with that kinda shit. No need for 1s compliement or 2s compliment. You could just increase the size. Yay
@jalf Its always last year, here jalf! :P
 
7:19 PM
If you want a less evil example, take std::iterator_traits. The reason why pointers can be used as iterators is that the "extra" functionality required for iterators (such as typedefs specifying the value type, or whether or not it is a random access iterator) are outsourced to the std::iterator_traits<T> template, which, by default, just forwards to the iterator type itself (so std::iterator_traits<T>::value_type is internally defined as typedef T::value_type value_type)
but for pointers, where such a typedef does not exist, iterator_traits is specialized to define those types itself
end result: even though pointers aren't class types like most other iterators, and thus can't directly define typedefs and such, the magic of templates allows us to treat them as just another iterator
 
Well, with StackOverflowGOLDPlusUltra2013 you can subscribe and have access to questions before they're even posted to the site. Yours for only $19.99/month! — tombull89 Apr 12 at 19:09
 
Basically, with templates you can make special rules for specific types, or groups of types (if T is a float, we should use this specialization. But if it is a pointer, we should use that specialization)
Generics just swap out a type, and nothing more. A List<bool> is the exact same implementation as a List<float>, just with one type name replaced by another
 
@jalf Avoiding naked pointers, which is awesome.
 
I feel bad for interrupting jalf's lecture. :)
 
@Mysticial :p
 
7:22 PM
@Mysticial Go die. Or watch anime.
 
don't worry, I'll shut up now :)
 
@jalf No no don't. You explain well.
 
@GamesBrainiac but I'm done now ;)
 
@jalf I get it now, well kind of, but I guess I need to experiment with templates more.
 
7:25 PM
@jalf Since you already mentioned bitfields, is there a reason why std::bitset takes the number of bits as a template argument? Why isn't it an argument for the constructor?
 
@GamesBrainiac yup, do that. You'll be surprised at the fun things you can do with them. Then you'll be horrified. Then you'll overuse them like crazy. And then you may reach enlightenment ;)
 
@jalf Or I could just use Haskell.
hahahahah
 
@GamesBrainiac yup, that sounds good too :)
 
20 mins ago, by Luc Danton
More often than not generic programming will make use of the type and data families extensions. Guess what that looks like in C++?
It's the same.
By all means use either or both though.
 
with help from Rapptz
 
7:28 PM
@JohannesSchaub-litb @LucDanton Any result yet? I’ve read all the messages in my absence, seems like a similar case doesn’t work on ideone. Where does this leave us?
 
We have no idea why it works, how it works, if it should work, but we know it's not reliable.
 
@KonradRudolph my conclusion is that the spec is not clear on it
 
hmpf.
Okay, but the workaround template <typename T, typename = typename enable_if<…>::type> should work, right?
 
Naked pointers scare me.
 
@KonradRudolph why not ::type = 0
 
7:31 PM
I'd rather stay with the non-type parameter style, although I don't remember how well Clang copes with that.
 
@JohannesSchaub-litb because then I have to make enable_if return an integral type, and then I could just as well use a parameter pack, no?
 
@KonradRudolph ::type* = nullptr
 
@JohannesSchaub-litb same thing, no?
 
@KonradRudolph no
 
oh, no, true
anyway, I prefer the typename=, I think
 
7:32 PM
@Mysticial Hey, do you have your hands on episode 11 of TWGOKs?
 
I thought that the conclusion was that the SFINAE doesn't work at all.
even if you use int
 
@JohannesSchaub-litb Erm. Ah? Well the robot clearly thinks otherwise if you look at his article on the subject
 
@KonradRudolph my sfinae test shows otherwise
wait, I will test something
that works fine even if Nopes<T> has no ::type
 
@JohannesSchaub-litb Well here’s the robot:
template <typename T,
          EnableIf<is_scalable<T>, is_something_else<T>>...>
T twice(T t) { return 2*t; }
 
@JohannesSchaub-litb I see no equals sign.
 
7:36 PM
@LucDanton the "..." idea doesn't need equals
 
3 mins ago, by Konrad Rudolph
anyway, I prefer the typename=, I think
3 mins ago, by Johannes Schaub - litb
I thought that the conclusion was that the SFINAE doesn't work at all.
 
@KonradRudolph clearly it is not reliable
 
Make sure to talk to one another please.
@JohannesSchaub-litb My codebase says otherwise.
 
@JohannesSchaub-litb It clearly seems reliable though, your coliru test just now notwithstanding.
 
@LucDanton i don't know about your codebase
 
7:39 PM
Non-type parameters work fine with GCC.
 
all I see is that it doesn't work in clang
just in gcc
so to me it seems unreliable
 
Even the non-pack version?
 
Everyone just loves clang.
 
@LucDanton no. only the "..." pack version has the flaw
 
Then between the type, defaulted version and non-type, defaulted version I would favour the non-type one. Can later upgrade to the pack style.
 
7:43 PM
Well, clang sucks
:p
 
in the past I was a fan of it too
Oct 8 '11 at 18:22, by Johannes Schaub - litb
template<typename T, sfinae<SFINAE MAGIC>... > void f() is perfectly readable IMO
@KonradRudolph i don't think that it is clear whether it is wellformed. I wouldn't write it
 
Oh, here we are:
> The big problem with this is that compilers are not yet perfect in their C++11 support. My tests show that GCC 4.7 is up for the task, but Clang 3.1 isn't yet. For clang I use the following workaround.
 
lol Clang 3.1
 
Why doesn't clang like the pack version?
Also typename = sucks
 
as I have shown, if you pass a dummy argument· like 0, it also accepts the pack version
 
7:49 PM
Anyway guys, thanks a lot for the discussion, very helpful. Especially considering that this chat is constantly off-topic and nobody ever talks about C++ here and it should clearly be frozen and then deleted.
4
 
:p
and buried
 
@JohannesSchaub-litb Yeah, I've had a discussion about that with Luc months ago.
 
… and where is the robot when we need him?
 
> Generic lambda and implicit function template commits reverted
dammit
 
no-opping or getting drunk
 
7:53 PM
@LucDanton reason?
 
> There's some additional work needed before these are ready for trunk. Specifically, I need to make sure there are no test regressions.
 
fuck
I need to stop eating things.
 
Ell
You need to see that surgeon sooner :o
Or specialist or whoever it was
 
Grrr, some nitwit is upvoting shitty comments claiming that friend is bad practice
1
Q: Private methods vs Lambda in C++

user1095108My question refers to: Using a lambda expression versus a private method Now that lambda functors are part of C++, they could be used to unclutter a class' interface. How does lambda use vs private method use compare in C++? Do there exist better alternatives to unclutter class interfaces?

 
@Ell I can't
 
8:01 PM
@KonradRudolph i have just upvoted all those comments
 
grr
et tu, Brute?
 
lol
 
in fact, I now upvoted all of that question. including answers
 
muh encapsulation
I used to think I was doing something wrong by using friend because people said "Good design comes from non-friend, non-member functions"
...and the corresponding entry in the FQA: yosefk.com/c++fqa/friend.html#fqa-14.2Josh Lee Dec 16 '09 at 12:16
lol
I'm glad no one does this anymore
 
@Rapptz Link the FQA once more here and you’re shadowbanned
… wait, it was a quote. Okay then.
Can we flag that comment as “offensive”?
 
8:06 PM
Nope!
 
Why is it forbidden to link to yosefk.com/c++fqa ?
 
@Assaf: yes, but the FQA is, for the most part a, a lot of incoherent angry gibberish without any real value. The part on friend is no exception. The only real observation here is that C++ ensures encapsulation at compile-time only. And you don’t need any more words to say it. The rest is bollocks. So, in summary: this section of the FQA is not worth mentioning. — Konrad Rudolph Dec 27 '09 at 21:28
Most of that FQA is utter blx :) — rama-jka toti Jan 15 '10 at 7:19
 
hey rapptz
 
hello
 
8:09 PM
@Rapptz oh my god, triple boner all the way
 
how long does food take to pass through the stomach?
 
depends what that means and on the person obv
 
@DeadMG i thought it's like 30 minutes?
 
well, I ate something, and I want to feel better about the probability of throwing up only some acid instead of my meal
 
That doesn't make much sense
 
8:11 PM
well, presumably I can't throw up what I ate if it's already passed through my stomach into intestines or bile thingy or whatever comes next
 
12 finger darm comes next
 
ah, whatever
I'd be critically afraid of vomiting for some reason even if I knew I'd keep my dinner
 
Emetophobia sucks.
 
well, logically, it's not that big a deal
I got a bucket right here
 
I am not going to click that.
 
it's not bad
 
8:42 PM
Lol. Apparently the German army just attested that their default rifle – G36 – is badly flawed. How is that news? All people I know who’ve done military service have been telling this a decade ago. And it probably was the same before that …
 
@KonradRudolph lol
anyone wanna fiddle with me?
 
1 message moved to bin
 
@Rapptz Sorry, why?
 
Sep 9 at 16:20, by Cat Plus Plus
Everyone laughing at you? Click here to learn how to make friends and not be hated!* We also have a list of acronyms, but it turns out that linking it here is extremely redundant. (* We reserve the right to laugh at you anyway)
 
@Rapptz Can't post Q here?
 
8:47 PM
no
 
Not like that, no.
 
@GamesBrainiac Yeah. Why?
 
@Rapptz Sorry what I did wrong then?
 
@Israel You posted a question here
 
@DeadMG Rapttz said not like this so now I'm confused. What is the proper way?
 
8:49 PM
Posting a question in this room is the worst form of taboo. Ever.
 
By being our friends.
I'm bored btw
 
@Israel We generally only permit people to ask questions here in one of two circumstances. Either you have an exceptionally interesting high-level question, which can happen very rarely. Or you are already a member of our community.
foo(x) {
    if (x > 5)
        return bar(x);
    return x;
}
bar(x) {
    return foo(x - 1);
}
 
@DeadMG I see. no, I have a noob Q so I'll go and kill myself.
 
@Rapptz Type checked this today.
@Israel Or just ask on Stack Overflow.
that's what it's for.
 
What's the type?
that looks like dynamic typing.
 
8:50 PM
@DeadMG Sure, thanks
 
@Rapptz Well, foo(x) is implicitly a template.
so if you call foo(0) then the result is int64 since I decided integral literals are signed 64bits until I work out the whole polymorphic typing thing.
 
user1804599
I'd make the widest signed integer the default.
 
user1804599
Or well in this case the function can just be polymorphic.
 
user1804599
Fuck monomorphism restriction.
 
@not-rightfold Strictly, LLVM goes up to 24bits. As in, the biggest bit width is 2^24.
and a backend has to emulate it, I believe, if it's not in hardware.
 
user1804599
8:53 PM
Well, the widest that Wide supports.
 
user1804599
Or are you going to support up to anything?
 
user1804599
int!42 :P
 
are there cheap systems that have bytes with a number of bits different than 8 on which one could test code?
 
user1804599
DCPU-16 VMs!
 
@Borgleader go to a museum with a PDP or something
 
8:57 PM
Oh they all died out?
 
although they won't have USB ports to connect your code to ;-)
35
Q: What platforms have something other than 8-bit char?

Craig McQueenEvery now and then, someone on SO points out that char (aka 'byte') isn't necessarily 8 bits. It seems that 8-bit char is almost universal. I would have thought that for mainstream platforms, it is necessary to have an 8-bit char to ensure its viability in the marketplace. Both now and historic...

 
9:11 PM
@not-rightfold I have considered having like, an int(64) style thing.
I might do that sometime
ah, fuck
so many days until 13th November
 
user1804599
9:28 PM
> You know you're fucked when you have a penis in your vagina.
9
 
Very perceptive.
 
Screensaver runs normally if as bat.
 
Yeah, I'm gonna have to think about this some more.
What bugs me, is that I don't have any paper.
I can't think without paper.
 
@EtiennedeMartel Think about what?
welp
five hours since I ate and I'm finally starting to feel a smidge better
 
9:46 PM
@DeadMG There's this thing I want to code.
I know what it should do, but I don't know how I'm going to do it.
 
what outcome are you aiming to produce?
 
I'm trying to write a docking library for WPF.
Because AvalonDock is crap.
 
a digital rubberduck might be an alternative to paper
 
obtw
 
@EtiennedeMartel a panel?
 
9:50 PM
since you prefer a language which can't cope with the notion of a strongly-typed interface
 
H E L L O ! !
shouting on the internet is the best, one might say that it's a little bit better than sex.
 
perhaps you'd care to advise me on the use of the run-time interface
 
@refp the better-ness of sex depends very much on whom you have it with
 
@JohannesSchaub-litb very true, let me rephrase that..
"shouting on the internet is the best, some might say that it's a little bit better than sex."
 
isn't the second part redundant if it already is the best?
 
9:54 PM
02
3
 
@JohanLarsson depends on how much you believe in something being the "best"
@JohanLarsson also; apelsinkanin.
 
tjusigt!
 
@JohannesSchaub-litb up to anything exciting?
 
@JohanLarsson it is not redundant with regard to how much it is better than sex for some
it is redundant only with regard to whether shouting on the internet is best
 
true, I failed
 
9:57 PM
litb; the one who can make even the simplest theory sound like something taken straight from a standard draft.
I haven't written a single line of code today (which is a lie, I've written plenty) but this headache is keeping me from focusing and I know I'll just rewrite it later.. which is why I still stare at the screen, write something, and then remove it
getting nowhere.
 

« first day (1064 days earlier)      last day (3898 days later) »