« first day (836 days earlier)      last day (4098 days later) » 

12:00 AM
@Drise because novices keep demanding we explain it to them over and over
 
85
A: How do I use arrays in C++?

FredOverflowArrays on the type level An array type is denoted as T[n] where T is the element type and n is a positive size, the number of elements in the array. The array type is a product type of the element type and the size. If one or both of those ingredients differ, you get a distinct type: #include &...

 
This just in: professional photographers take good photographs.
2
 
Impossible
 
What has the world come to?
 
12:01 AM
I think, you guys are misunderstanding me. I know, an array allocates space for its elements while a pointer is just a pointer.
 
Who knew
 
But if you only consider the variable
 
No.
 
Absolutely not.
 
12:01 AM
@DavidFrank an array is a different type with a different size than a pointer.
 
just stop, seriously.
 
I already linked to the two FAQs on this. Now I'm really going to sleep :)
 
the only things that link arrays and pointers is that an array can convert to a pointer, and offers indexing.
that's it.
 
@DeadMG does the array technically offer indexing or is it the pointer conversion that causes indexing to work?
 
@DeadMG When you pass an array, you are actually passing a pointer.
 
12:02 AM
@DavidFrank not always
 
@DavidFrank Arrays decay. Sometimes. Just stop. Use std::string, boost::string, or Qt::QString.
 
@DeadMG any ideas or is the allocator rebind test case convincing that unordered_map is not rebinding in gcc 4.5.1
 
@DavidFrank Only because the array decays into a pointer.
 
@MooingDuck Dunno. That stuff is a dark corner of the Standard and it's best not to think about it.
 
12:03 AM
@MooingDuck Latter.
 
@DavidFrank No, the syntax for a one-dimensional array as a function argument actually means pointer. Just stop.
 
See, this is why I became so hateful.
 
@doug65536 No.
 
@doug65536 if it works with std::allocator, then you know the problem is with your allocator somehow.
 
if you try to use an allocator which is otherwise perfectly functional, but does not offer rebind
then it fails to compile, when the implementation clearly attempts to access it.
 
12:06 AM
@DeadMG cool test
 
I'd really describe it as the obvious test.
 
Allocators are awful
 
I have no idea how the hell your test was supposed to prove anything.
 
you don't put a hard-wired std::pair as the template argument for a custom allocator right? How do I know it's always std::pair? or is it always std::pair in unordered_map
 
always
 
12:08 AM
TestAllocator<std::pair<Foo,Bar>> works in the typedef
 
Thank you for the enlightening
 
const Foo, nub.
 
@doug65536 it's probably not actually a pair in unordered_map, it probably allocates something else doesn't it?
 
well, I don't even know if the initial parameter matters
 
12:09 AM
it's a pair, but I'm taking an implementation detail right?
 
@doug65536 No.
 
@DeadMG shouldn't
 
lmao. using double works too.
 
@doug65536 right, that's how it's supposed to work
 
so lesson learned is allocator<void> is crap, so just throw some crap type in there and be done with it?
 
12:11 AM
One more question. Last time I asked, how you defined a function that takes a vector containing elements of type X or its subtypes. Now I'm asking how you define a function which takes a a vector containing elements of type X or its subtypes or a vector containing only some subtypes of X.
So
 
I suspect that it would be a template template, but C++03 did not have the correct mechanism to make that work.
 
@doug65536 or write your allocator<void> properly. You can't construct your allocator<void> from a different allocator type for instance.
 
@MooingDuck It can't work- no reference or const reference members
 
@DavidFrank what, like void function(const std::vector<std::unique_ptr<X>>& cont)?
 
it can, deadmg already pointed that out: template<typename U> TestAllocator(const TestAllocator<U> &other) { }
 
12:13 AM
class XSub : public X {};
class XSub2 : public X {};

I would like to be able to pass a vector<XSub*> and a vector<XSub2*> and a vector<X*> to the function
 
@doug65536 no, the non-void can convert, but your void specialization can't
@DavidFrank ah, that is trickier.
 
@DavidFrank Container covariance is impossible.
 
what? no deadmg's statement was right, can't do reference to void
 
@DeadMG templates
 
C# had XSub2[] could become X[], and they definitely regretted it.
@MooingDuck Still impossible.
you will have to take std::vector<X*> and simply construct it from the contents of the other vector.
 
12:14 AM
@DeadMG Did your stomach issue get better?
 
Iterators.
 
I would like to say something like
vector<? extends X> abc
 
@R.MartinhoFernandes Or template.s
 
Do not accept containers, accept ranges.
 
@DavidFrank You can't. Well, actually, you can.
 
12:14 AM
Unless you truly need the container functionality.
 
@DeadMG seems like SFINAE could do it no problem.
 
you can use a template and then find SFINAE.
 
should I just put a dummy type in testallocator<void> for reference and const reference?
 
@DavidFrank That is broken. In Java too.
 
@DeadMG I SAID THAT
 
12:15 AM
what if sfinae?
 
@doug65536 That won't make it less broken
 
@MooingDuck Yeah, but I thought of it when I edited my message, which was before your message.
 
wait a sec, i google it
 
@DavidFrank Why do you want that?
 
I'd forgotten that he might not mean "Must be binary compatible, i.e. not a template".
 
12:15 AM
@CatPlusPlus are you cryptically saying that the void specialization is wrong in my test?
 
@doug65536 I think it is.
 
@EtiennedeMartel Just comparing language features
 
@doug65536 Allocators construct as well as allocate, so allocator<void> doesn't make sense
 
@DavidFrank In C++, you can do this thing using SFINAE.
and it's a hell of a lot safer than what Java does.
 
I thought the spec requires you to make a specialization for void
 
12:16 AM
vOv allocators are awful
 
Did I mention iterators?
 
@doug65536 No.
 
Did I mention ranges?
 
allocator<void> doesn't make any sense whatsoever.
 
@DeadMG Can you give me some arguments or links why you think that?
 
12:17 AM
Allocators don't require a reference member.
 
you can make an implementation of an allocator that wraps opencl memory buffers, and sets up DMA-able memory for containers. that sucks?
 
@DavidFrank Java cannot maintain type safety in generics. C++ does.
 
I have an idea
 
@DeadMG If you use generics consequently, it can.
 
Let's not talk about Java generics again
 
12:18 AM
@DeadMG It can, but only at runtime.
 
@doug65536 Those nested types are not needed.
 
not to mention things like specialization
 
room topic changed to Lounge<C++>: We don't like to talk about Java generics. [c++] [c++11] [c++-faq] [get-out] [no-questions]
 
@R.MartinhoFernandes what nested types
 
and Java generics have a billion limits
 
12:19 AM
reference and const_reference
 
Ok, new topic
 
@DeadMG You might be exaggerating.
 
When will c++ support function recognition?
 
@DavidFrank Support what?
 
12:19 AM
@DavidFrank You mean reflection?
 
Did that silliness about charstars stop yet?
 
Nope.
 
@Drise yes
 
eg.
 
I never heard that term before.
 
12:20 AM
@DavidFrank never heard of that
 
int main() {
a();
return 0;
}

void a(){}
//boom compile time error
 
@DavidFrank never
 
Never-never land.
 
you have to indicate, you have an a method before calling main
This is insane
 
12:20 AM
@DavidFrank Because C++ has a single pass parser.
 
The compiler could just read 2 lines more, it could find it
 
Then go find a new language.
 
it is, but it's quite unlikely that it will ever be fixed.
 
@Drise I did
 
@DeadMG It's trivial in regards to OOP in C++
 
12:21 AM
How does it make sense?
 
@EtiennedeMartel It's more because of its semantics.
 
Why do you want a() to be on the bottom of main?
Why can't it be on the top?
Would it destroy your code base?
 
@R.MartinhoFernandes Aren't semantics a side effect of the fact it's a single pass parser?
 
@DavidFrank It made sense in 1970, and nobody has changed it to preserve existing code and programs.
 
@Rapptz When you have 1000 functions in 100 classes, you dont want to think about reordering them, and put stupid class Foo; -s everywhere
It just freaks me out.
 
12:22 AM
@DavidFrank Then why are you here?
 
@EtiennedeMartel Not really. That would be easily fixed.
it's more about the TU model.
for example, the compiler cannot pass over other source files, so the vast majority of declarations would have to remain
 
C++ could be such a cool programming language, and parallely it has these stupid unproductive "features".
 
This has never, and will ever be an issue for me or probably anyone who has written sane C++ code.
 
@DavidFrank When you have 1000 in 100 classes you don't have them in the same file anyway.
 
@DavidFrank Lol, features. You sound Like Tim Cook at a press conference.
 
12:23 AM
@DavidFrank It's old as fuck.
It drags legacy.
 
@EtiennedeMartel Not really
 
And it still manages to adopt modern features quicker than Java.
When does Java get closures? Java 8, right?
 
Tell me then, maybe I'll switch from C#. Or not.
 
Java already has closures, they're just half-assed
 
12:24 AM
@EtiennedeMartel Lol, without introduing Day-0 vulnerabilities.
 
@CatPlusPlus Not really.
 
@R.MartinhoFernandes The fact, that you have to manage headers in two files, makes it so unproductive in the first place.
 
It's getting lambdas in 8
 
@DavidFrank manage headers in two files?
 
12:24 AM
@DavidFrank ?_?
 
@Zoidberg Not really. It's weird, but not really scary.
 
@R.MartinhoFernandes taking out reference and const_reference breaks it
 
@R.MartinhoFernandes Inner classes can close over fields from outer scope
Local things have to be final though
 
@CatPlusPlus And make them 1-element arrays, you mean?
 
@DavidFrank You may want to stop while you're behind. Just saying.
 
12:24 AM
Because it's primitive
@R.MartinhoFernandes I don't know about primitives
But I doubt it does that to ~real~ objects
 
@Rapptz @MooingDuck You need to define your functions in the .h files and then explicate them in the cpp files
 
@DavidFrank oh. yes. "declare" in the header, "define" in the cpp
 
DRY?
 
It isn't explicitly being forced upon you
 
@DavidFrank Better than Java-all-in-one files
 
12:25 AM
EX-PLI-CA-TE
 
Nothing is stopping you from making it header only.
 
Headers are just a convention
 
@DavidFrank Don't Repeat Yourself.
 
Albeit slower compilation times.
 
@Drise No, it's not better than modules
 
12:26 AM
It doesn't really apply here.
 
user142019
Java is terrible without navigator or code folding.
 
user142019
Wait
 
Implementation should be hidden from the interface.
 
user142019
Java is terrible.
3
 
@EtiennedeMartel isnt this about repeating? for every single function?
 
12:26 AM
@DavidFrank I don't know, I dump all my code in the headers anyway.
 
lots of C++ libraries are header-only.
 
Because after dealing with C++ tools and especially build systems you usually want to kill yourself
 
Dont talk about java. I dont know about a single programming language except for c++ which does this.
 
@DavidFrank C?
 
lol
 
12:27 AM
LOL
 
@CatPlusPlus Speaking of which Jigsaw was delayed to Java 9, i.e. Java will only have whatever they call modules... in some years.
 
user142019
Objective-C. lol
 
Makes no sense to me. If you want to loosely couple interfaces and implementation, use interfaces.
 
@DavidFrank oh, but that they're trying to fix soon. "Modules"
@DavidFrank interfaces slow the code down
 
user142019
An indeed, don't talk about Java. Or C++. Or other abysmal languages.
 
12:28 AM
@MooingDuck At least they're trying.
 
@DavidFrank That is not the point.
 
@DavidFrank It's not related to that
 
@Zoidberg Like Haskell?
 
@EtiennedeMartel ok, they are the same in this regard.
 
It's just that there is no metadata.
 
user142019
12:28 AM
Haskell is a great language.
 
user142019
Like Erlang and Elixir.
 
I mean, at least C++ has a committee that's actively working on improving the language. Java has the JCP, which... is shit.
 
Haskell -> Monads?
 
user142019
And Perl.
 
Complete and utter shit.
 
12:28 AM
So you need to lug the metadata around by hand if you want it.
 
Always sounds like gonads
 
@R.MartinhoFernandes Eh, it's still better now than C++ model ever was
 
@Zoidberg Elixir? The fuck is this? Another buzzword-driven language?
 
user142019
@EtiennedeMartel not really.
 
@CatPlusPlus No doubt.
 
12:29 AM
@Zoidberg And now you're trolling.
 
Ok, lets not talk about java.
 
user142019
It's quite unpopular.
 
Let's not listen to Zoidberg either
 
user142019
@EtiennedeMartel No, I'm serious.
 
But c# neither has this "two file for each class" thing
 
user142019
12:29 AM
Perl is great.
 
He's insane
2
 
user142019
I love it.
 
one is exactly enough
 
@DavidFrank It's a convention
 
Ah, nothing like one against the room in "Please tell us how much shit C++ is!". Here with your hosts, the mods of the C++ Lounge!
 
12:29 AM
@CatPlusPlus He's from the People's Republic of Madbodia.
 
@DavidFrank I already told you earlier -- Nothing is explicitly forcing you to use two files for a class.
 
@CatPlusPlus But its just so counterproductive
 
David, you're not getting the point.
 
user142019
Well make everything header-only then.
 
It's not a feature, it's an artefact
 
user142019
12:30 AM
PROBLEM SOLVED.
 
@DavidFrank Sigh. It's not mandatory. If you think it slows you down, don't do it.
 
headers were a necessity a long time ago, and we can't get rid of them without breaking a lot of stuff right now.
so they have to stay.
it's not something we want or think is good.
it's just the way things have to be.
 
@DavidFrank Not as much as Java's boilerplate.
 
Also, it's still less counter-productive than writing anything in Java
 
@DavidFrank C# is "a better Java", so of course it borrows lots of concepts.
 
12:31 AM
Assembly is a better Java because it's not very hard to do
 
@EtiennedeMartel Much better.
 
@EtiennedeMartel Except it does not borrow the idiotic "File name must match class name and only one public class per file".
 
user142019
If you want decent module system use Haskell or Python or Erlang.
 
user142019
Or Node.js.
 
I'll poke holes in C# all day, but it's definitely substantially better than Java.
 
user142019
12:31 AM
C# is fine. And Java isn't. That's the biggest difference.
 
Erlang has flat hierarchy
 
user142019
Doesn't matter. Convention is prefixes.
 
It does matter
 
user142019
_ isn't really much different than / or ..
 
It's not very good
 
12:32 AM
@Zoidberg Lol, I had a friend try to make a website in Node. Lets just say after 18 months, he switched to RoR
 
@CatPlusPlus Oh yeah, and there's talk of removing primitives in Java 10. vov
 
@Zoidberg It is when you consider relative paths
 
user142019
@Drise what a noob.
 
user142019
-pa flag.
 
btw
I heard that when we have modules, we will still have to have declarations.
 
12:33 AM
@R.MartinhoFernandes Will they fix ==? :v
 
if that's true, what the fuck is the point of modules?
 
@Zoidberg Hipster Lobster.
 
@CatPlusPlus Probably not.
 
user142019
@DeadMG Less macro hell.
 
Java has some major issues. Fact. It's sad. But that doesnt make C++'s idiocy better.
 
12:34 AM
@Zoidberg Good point. He is in fact quite the nub.
 
user142019
@EtiennedeMartel :D
 
@DeadMG Latest proposal I've seen exports declarations in the "compiled" modules automatically.
 
@Zoidberg How is that going to happen? I still need to use #include to get the declarations.
 
@DavidFrank You really need to stop.
 
user142019
@DavidFrank No. Java is a major issue.
 
12:34 AM
Oh wait, that's right! I have the ignore power!
 
@DeadMG hope you're wrong.
 
Java is a primitive piece of crap
 
@DavidFrank What the fuck is wrong with you? Read what I said. It's not a choice.
@R.MartinhoFernandes So for all things in module files, we won't need declarations?
 
user142019
@DeadMG When you import modules it won't import all macros and shit, I suppose. (And if it does, I'll kill the designers of the module system.)
 
Oh yay! I forgot about that power.
 
12:35 AM
@DeadMG that also doesn't make it better
 
user142019
Java is C with exceptions and GC and bad OOP and less UB.
 
@DeadMG You wouldn't use the preprocessor for that.
 
@DeadMG Right. #include will still be around, but the headers will contain nothing but import whatever and possibly macros (like that assert thingy).
 
@MooingDuck Right, but C++ wasn't stupid or idiotic to adopt headers. It was necessary.
 
@DeadMG automatically generated headers, I thought that was the point.
 
12:36 AM
@Drise Why? I'd love to like c++, but there are just a few things, which pisses me off
 
Essentially, it's about treating the whole module as a TU.
 
@Zoidberg Java has UB, and is not "C with exceptions"
 
It wasn't necessary
 
@DavidFrank Do some C#. Try coming back to Java. GL HF.
 
user142019
@MooingDuck TIL. Example?
 
12:36 AM
@DavidFrank And you are complaining about quite possibly one of the dumbest things that is set to change in the near future.
 
11
Q: What are the common undefined behaviours that Java Programmers should know about

hhafezThe same as this question but for java Update Based on the comments and responses of a few people, Its clear that Java has very little undefined behaviour. So I'd like to ask as well what behaviour is not obvious. Please when answering make the distinction between the two :)

 
@MooingDuck No that would be stupid
 
@R.MartinhoFernandes What about stuff in the same source file?
 
@DeadMG What do you mean?
 
well, presumably, if you're compiling main.cpp, you can't import main, because it doesn't exist yet.
 
12:37 AM
Would be cool if modules worked like .NET assemblies.
 
You all should have seen the look on my Java professor's face when I turned in an assignment in C++/Qt. Hilarious.
 
@DeadMG make prototypes, compile to get the "import" data, then compile the rest now that the import data is there.
 
That's silly
 
user142019
@MooingDuck answers are a bit lacking IMO.
 
@EtiennedeMartel Oh. You may need declarations as usual to break circular dependencies, but that's all.
 
12:38 AM
and always having to import yourself would be dumb.
 
user142019
Not very useful.
 
Just compile modules with multipass enabled, like classes
 
@EtiennedeMartel You mean like Using System.Windows.Forms?
 
@Zoidberg yes, I ran into some recently, but can't recall what it was
 
@Rapptz Not using.
 
12:38 AM
I'm calling my allocator thing solved. lesson is don't bother with void speciailization and just put int for the allocator template parameter and let it rebind the real allocator template when typedef'fing a pair container
 
user142019
@MooingDuck ah okay.
 
@Rapptz That's namespace flattening
 
using is for namespaces. I'm talking about assemblies.
 
What do you guys develop using c++?
 
@EtiennedeMartel Ah -- I wouldn't know their technical names on the C# side of things.
 
12:38 AM
Visual Studio
 
Nothing because it's a terrible language
 
user142019
Use Ruby!!!! And CoffeeScript! And Erlang!! And C!!! HIPZORZ!
 
@DavidFrank A game engine.
 
user142019
IT MAKEZ YOU COOL!!
 
@DeadMG Do you develop VS?
 
12:39 AM
uh, no?
 
@MooingDuck WTF, why would you need to import yourself.
 
there are millions of users of VS and probably a thousand or less developers working on it.
 
user142019
@DavidFrank A Zoidlang implementation.
 
the probability of a random user being a VS dev is essentially negligible.
 
@DeadMG He asked what you write with C++, not what you write C++ with.
 
12:40 AM
@Zoidberg You mean, another project you'll never finish?
 
@R.MartinhoFernandes ohhh.
 
@EtiennedeMartel Yes
 
user142019
@EtiennedeMartel exactly.
 
@DeadMG yeah what the robot said nub
 
@EtiennedeMartel How is it working in the game industry?
 
12:40 AM
:D
 
user142019
Finishing projects is boring.
 
user142019
Code older than one day is terrible.
 
What ever happened to Radek?
 
user142019
That's me, you fool.
 
@DavidFrank I work at a small developer, so no crunch time.
 
12:40 AM
@Drise He's Zoidberg.
 
user142019
lol
 
@Drise Zoidberg ate him.,
 
@Zoidberg You sound like Shirlock
 
@EtiennedeMartel Xeo does crunch time on weekends!
 
@Drise Yeah, he's a kid, so he still don't know who he is yet.
 
user142019
12:41 AM
@Drise Okay.
 
@R.MartinhoFernandes Maybe it's shit in Germany.
 
user142019
@EtiennedeMartel lul
 
@EtiennedeMartel I read topics on so about how much it sucks to be a game developer. Doesnt it apply to you?
 
@EtiennedeMartel Twas a joke on the fact that he was at work on the weekend because he cannot browse the interwebs at home.
 
@DavidFrank No.
 
user142019
12:41 AM
Real hipsters use C.
 
If I leave late (which is the case today), it's because I got in late.
 
He's got no soul already
He worked at Ubisoft
 
@Zoidberg No, only twat cakes.
 
user142019
lol Ubisoft
 
user142019
Prince of Persia was a nice game.
 
12:42 AM
@CatPlusPlus On a small team, working on a prototype. Still no crunch time there.
I had it easy.
 
Interns don't crunch.
 
3D platformers are annoying
 
user142019
| genre = Platformer, action-adventure, hack and slash | modes = Single-player | ratings = | platforms = PlayStation 2XboxGameCubeGame Boy AdvanceWindowsPlayStation 3 | media = Optical disc, Cartridge | requirements = Windows * Windows 98SE/Me/2000/XP * Pentium III/AMD Athlon 800 MHz or faster * 256 MB RAM or greater recommended * GeForce 3 or higher (Excluding GeForce 4 MX) * DirectX 9.0a (included on CD) * 1.5 GB minimum hard drive space * 16X or better CD-ROM * Windows compatible mouse (with wheel) / keyboard required. }} Prince of Persia: The Sands of Time is a third-p...
 
@R.MartinhoFernandes Even the people on my team did not crunch.
@CatPlusPlus Played Rayman 2?
 
Long time ago for a while, don't remember
 
user142019
12:43 AM
Time to install Elixir.
 
@CatPlusPlus Well, it was good.
 
What happened to Jim Norton?
 
Also, the Mario games are good. But it's because Miyamoto made then, and anything he makes is good.
@Drise Chimera?
 
Ye
 
I think I saw him earlier.
 
12:44 AM
And Cicada?
 
@Drise She comes once in a while.
 
I bet
 
@Zoidberg I worked with a bunch of people who worked on the PoP 2008 reboot.
 
@EtiennedeMartel I hated that game
 
Turns out the development did not go so well.
 
12:45 AM
@Drise She's competing in the new official Lounge sport: dropping out of school.
 
@MooingDuck What.
 
@EtiennedeMartel hate
 
@R.MartinhoFernandes Nice. My roommate got thrown out after giving me endless shit about how terrible my school habits are.
 
@EtiennedeMartel I'm not a big fan of platformers though
 
@MooingDuck But, Michel Ancel! That sexy dude.
 
12:48 AM
@EtiennedeMartel I played Croc though
2 I think
 
user142019
@EtiennedeMartel ok.
 
@Zoidberg The game was shit.
 
user142019
lol
 
@R.MartinhoFernandes You know, this has become quite common for some reason.
 
@Zoidberg In short: if a game has a rocky development, 99% of the time it's going to turn out shit.
 
user142019
12:52 AM
:P
 
Most of the time it's the designers' fault.
 
user142019
Oh cool Elixir has string interpolation.
 
Why do you see a lot of open source projects hosted on multiple sites (ie. on github and sourceforge, ohloh, etc)?
 
if you don't specialize operator=, then the compiler will just make a temporary on the right hand side using an implicit copy construct and assign from that, right?
 
@Drise Are you a nun?
 
12:57 AM
@doug65536 effectively, yes
 

« first day (836 days earlier)      last day (4098 days later) »