« first day (1477 days earlier)      last day (3470 days later) » 

12:00 AM
6
Q: How can I initialize C++ object member variables in the constructor?

David EnglundI've got a class that has a couple of objects as member variables. I don't want the constructors for the objects to be called when declared, so I'm trying to hang onto a pointer to the object explicitly. I have no idea what I'm doing. o_O On stackoverflow, I seem to be able to find other exampl...

 
user4655569
Alright these arent pointers and i dont want to use the damn initializer lists.
 
user4655569
I dont like this syntax, comming from java :P
 
Err, the initializer list has nothing to do with pointers.
 
user4655569
I know, but its used in the post.
 
user4655569
These 2 ways.
 
12:05 AM
Post an example of the class and where the object is placed inside the class.
 
user4655569
 
Test::Test() : object(...) {}
that's the answer
 
user4655569
Yes about that list, but unfortunately i want to calculate the parameter
 
so, calculate it
 
user4655569
#Genius. If i calculate it, its a global variable.
 
12:15 AM
Go home. You're drunk.
 
lol
 
I think it will have to be more than just global to be used there
it will also have to be compile time deducible
I may be wrong here though
 
user4655569
I just use a fucking pointer, its ten times easier than.
3
 
don't use a fucking pointer
sexual intercourse pointers are almost never the right choice
use protected_ptr for safety
 
user4655569
:D
 
user4655569
12:18 AM
@sehe You're a german guy ?
 
If you don't make an example, I guess nobody will understand you
 
user4655569
Okay, i' ll give an example
 
user1804599
g=> (sample pos-int)
(0 0 2 1 2 2 5 2 8 7)
 
user1804599
wtf
 
user1804599
since when is 0 a positive integer
 
12:22 AM
I like take in Clojure btw, it's nice for some reason
it makes sense
 
user4655569
 
that's not an example
that's what I gave as a line of code + 5 lines of comments
> thats has to be declared and calculated before
before what?
> "arg1" cannot be resolved
what does that mean?
 
Ell
opengl woop
 
Ell
it looks awful but it works
 
user4655569
12:25 AM
Do you expect me to post my real code ? What it means ? The variable is not defined.
 
user4655569
Its my problem, abstractly formulated.
 
@Ell I cant find where i hosted it but i was once able to render a gun model i got from blendswap using opengl.
anyway, im off
 
user4655569
Yeah, i could have done this, but i think its not worth it.
 
Ell
@Borgleader that is a distorted suzanne
 
12:30 AM
@Ell GlaDOS : You monster
 
> Flanders Reds are commonly referred to as the "red" beers of West Flanders. Belgian Red Beers are typically light-bodied brews with reddish-brown colors. They are infamous for their distinct sharp, fruity, sour and tart flavors which are created by special yeast strains. Very complex beers, they are produced under the age old tradition of long-term cask aging in oak, and the blending of young and old beers.
this has to be the most extreme shit I've tried so far
at first I thought it was acid
the smell didn't help much
 
12:49 AM
s/most extreme/worst/
 
Ell
1:10 AM
Fuuuck
Is it possible I broke multitouch by dropping my phone?
 
Maybe
I'm changing networking setup
rip loungecppdotnet
 
Ell
Oh no its a software issue.
 
1:41 AM
@Ell no that's impossible
something else must have broken it
 
Ell
Restarting fixes it (temporarily)
Redditor @Rapptz wants to battle
 
TIL about const void
 
Ell
Do go on
 
For some reason I never even thought about it. Even though I've used void, void* and const void*
@Ell It seems to be kinda useless.
37
Q: What's the point of const void?

FredOverflowApparently, it is possible to declare a function returning const void: const void foo() { } g++ seems to consider the const important, because the following code does not compile: #include <type_traits> static_assert(std::is_same<void(), const void()>::value, "const matters"); So does cons...

I suppose for every T there's a const T and they had no reason to make an exception for void.
 
Ell
1:56 AM
Yeah
I wish return void would translate to return
I wonder why it doesn't
It'd save a load of duplication of wrapping function like things
 
you can return void();
 
2:17 AM
TIL about this
This is one cool app.
 
2:28 AM
Any vim users here?
 
that's not well formed
 
that's the proper way of doing it
 
well that's easy to say :)
 
 
2 hours later…
5:14 AM
I. AM. SO. FUCKING. LUCKY.
Remember that phone I lost on Tuesday? Someone found it and took it. And they happened to be one of my friends! So I got it back today!
 
@R.MartinhoFernandes Congrats!
Not surprising though, Berlin being such a tiny little burg in the middle of nowhere, and you having lived there your whole life, of course everybody who could have found it is a friend.
 
5:34 AM
kek
 
5:50 AM
now you can phone again
@R.MartinhoFernandes what your the German/English ratio of daily conversation?
I mean, you speak German to the natives, but probably you encounter many who don't speak it fluently so you resort to English.
 
6:29 AM
I am so tired these a few days ... fell asleep after had two cups of coffee just now
 
cpx
Why does this answer says you cannot do this? I'm not even using C++11 if it requires that.
 
they're talking about different types
like int and float.
 
cpx
Ah.
Confused me.
 
the struct answer is clever
 
6:31 AM
auto ij = std::make_pair(1, 1.2);
@Rapptz wow inline struct
"forstruct" sounds kinda cool
 
I'd like something like enumerate in C++
 
what's that?
 
Could just make my own again.
@StackedCrooked In python: for i, val in enumerate(list): would give you the index and the value
 
you could create a helper like index = [&]{ return &i - &list.front(); }.
 
only works for contiguous things
enumerate works on all iterables.
I had one I just deleted it
 
6:39 AM
dunno which iterator category and stuff
> Is dell computer is litle or big endian
 
7:20 AM
@R.MartinhoFernandes It's stranger when you acccidentally swap phones with a friend and, next morning, you get a call from yourself.
 
user1646075
8:13 AM
@nightcracker does six hours later help?
 
@aclarke Nothing can help vim users. They are all doomed.
 
user1646075
@MartinJames I'm enjoying my descent into the pits of hell.
 
user1646075
also, too lazy to even begin to learn an alternative
 
user1646075
Anyway, people need vim. It's important to know that not everything is orthogonal, logical or follows any kind of plan.
 
user1646075
I Wonder if vim users are statistically more likely to be athiests
 
8:15 AM
@aclarke I'll see you there. The coffee and paracetamol are not working.
 
user1646075
I'm finding that a whiskey + cherry wine mix works well...
 
user1646075
time for the 2nd i think
 
@aclarke I'm pretty sure that any more alcohol is a bad idea ATM. My stomach is in a worse state than my head. I have a bucket handy in my office, just in case.
 
user1646075
@MartinJames oooops - good luck then. Don't even think about having sausages, bacon and egg for lunch, or anything greasy or heavy.
 
@aclarke I may try a slice of toast later. Much later.
 
user1646075
8:21 AM
I'm just spending a lazy saturday afternoon sorting out my pr0n i mean torrents I mean legitimately acquired music, movies and other general objects that have managed to get themselves disorganised across 4 different terabyte disks. It's such a hassle trying to figure out a logical structure for all that.
 
user1646075
So, you had a huge friday night that you're still coming down from?
 
@aclarke Hmm.. my current disk for err.. non-copyrighted downloads has only 4G left:( Need to buy another disk.
@aclarke Yeah - charity gig at club. I bid on three items at the auction and got none, I won nothing in the raffle and the only thing I came home with is this hangover. Not one of my better nights, TBH.
 
user1646075
At least you drove the price up, so that's contributing to the charity.
 
@aclarke Yeah - that's what I keep telling myself:)
 
9:05 AM
@BartekBanachewicz How do you do the activation gesture? I am struggling with that one.
 
cpx
I will need to learn Java just for an Android App on my phone.
 
@cpx Learning Java is a breeze if you already know any other language.
@StackedCrooked TIL
 
@FredOverflow I had learned about it 10 seconds earlier.. So that put me in a position of authority :P
 
return; -> return void();
 
9:26 AM
Hi all
 
cpx
@FredOverflow How is that? Because it is object oriented, imperative, generic, and has functional features as C++?
 
lol no.
 
This map is so flat:
flat_map<const std::type_info*, flat_set<AbstractSession*>> sessions_;
 
@cpx Because there is nothing special about Java, except for checked exceptions and wildcards.
And those are both awful language features.
 
@FredOverflow And Gosling
 
9:31 AM
> Our Senior Data Analyst has built an awesome cross-functional team to work on optimization, by bringing together campaigners, engineers, and analysts to super-charge our digital program. As our new Data Analyst, you will be supporting every aspect of that experimental work, as well as handling critical data tasks, such as creating SQL reports, monitoring email deliverability, and integrating data from third-party systems.
sounds delightful
 
cpx
I guess I'll learn to hate it too once I'm through with it.
 
> Consistently spots when data looks wrong, and is emotionally compelled to figure out why
 
:19730930 wants?
 
@LoĂŻcFaure-Lacroix If they had put the 'creating SQL reports, monitoring email deliverability, and integrating data from third-party systems' at the top, it would have saved reading the rest of the bumph.
 
I'm not 100% sure if it can be null.
 
9:35 AM
It can :(
Optional<String> o = null;   // perfectly valid Java 8
Maybe this will become a compile-time error in Java 9 (or whenever Java gets value types).
 
Well, I suppose this could be compensated with warning levels.
 
No it can't, because what's the default value for reference type data members?
 
What does Optional<T> use for its nullopt or Nothing
 
Or static analysis. Java kinda always depended on the IDE.
 
This grape looks like a butt.
 
9:37 AM
@Rapptz What? Please clarify.
 
pics or it didn happen
 
optional<int> x = nullopt; // C++
what does Java use instead of nullopt?
 
they use some kind of named constructor
 
user1804599
Optional.empty().
 
Optional<String> o = Optional.empty();
 
9:39 AM
@FredOverflow The <T> is not required for the .empty call?
 
No, Java has some type inference.
 
nasty
 
user1804599
Java has type interference.
 
Seems like a weird kind of inference.
 
They should have done what C++ does and make null a type of NullPointerType
:p
 
user1804599
9:40 AM
No, that's extremely dumb.
 
Is it?!
 
user1804599
You can already say Optional<T> x = null; in Java and it means something different.
 
@rightføld You can't have the equivalent of Some(null) in Java. Is that good or bad?
 
user1804599
Bad.
 
user1804599
It's inconsistent.
 
user1804599
9:41 AM
It makes writing any abstraction that uses Optional and where null is a valid input impossible.
 
Couldn't you use Optional<Optional<T>> as a workaround for those scenarios? ;)
 
std::optional seems better designed
 
user1804599
@FredOverflow No.
 
Does std::optional have useful HOFs like flatMap and whatnot?
 
@Rapptz well no shit
 
9:45 AM
Note: whatnot is not a HOF ;)
 
user1804599
Is std::optional<std::optional<T>> possible?
 
you know
 
user1804599
If not, it's instantly doomed as it makes writing generic code impossible.
 
@rightføld I don't see why it wouldn't be.
 
template<typename T> struct optional<optional<T>> : optional<T> {};
 
9:46 AM
there's no reason why it should not be possible.
@StackedCrooked Bad idea.
 
But neat :P
 
user1804599
I heard somebody say it was impossible a few months ago.
 
user1804599
How does it deal with std::optional<std::optional<T>> f() { return nullopt; }?
 
the outer optional contains nothing.
there's nothing interesting about optional<optional<T>>
 
user1804599
@Puppy Nice.
 
9:48 AM
Each level of nesting reduces the chance of having a result. So you can use nested optional to overload on likeliness of success.
 
also a bad idea.
 
What do I include if I want to use optional on g++?
 
boost/optional.hpp
Is std::optional gonna have significant differences from boost::optional?
 
@StackedCrooked touché
 
not really.
 
9:50 AM
@FredOverflow did you try experimental/optional?
 
Yes, whenever you handle an image you can get it dirty and this hurts the quality. Try holding your JPEG by the edges to avoid getting fingerprints on it. — foobarbecue 6 hours ago
 
@bamboon file not found
Is that the final cover? The bird is so ugly :-/
 
user1804599
C++ is also ugly, so it fits well.
5
 
lol
 
@FredOverflow that's bad
 
user1646075
9:53 AM
 
user1646075
should be this picture
 
lol
"C++11 for programmers", really? What is next, C++11 for housewifes?
 
well, there's scientists, engineers, and say, game developers as well.
Although for the latter you might argue they are programmers in a sense.
 
And those people need a different approach to learning C++11?
 
C++11 for hobbyists
 
9:56 AM
Yeah. Scientists are taught to write terrible unmaintainable code, engineers need to use #define everywhere even in C++11, and game developers need to use long API name functions.
 
@FredOverflow works for me, though. gcc 4.9
 
Game developers? Aren't those the people who benchmark debug builds and debug release builds?
 
user1804599
C++11 for C++14 programmers.
 
user1804599
No, they don't benchmark. They make assumptions.
 
@rubenvb they use it to the level of their understanding.
 
9:57 AM
@bamboon g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2
 
@FredOverflow Needs to be GCC 5.0 aka trunk.
 
@FredOverflow It's supported as of 4.9. gcc.gnu.org/gcc-4.9/changes.html
 
Maybe 4.9 (or later) has it?
Oh neat.
 
user1646075
@FredOverflow Yeah, so they can program their kitchen computers to cook
 
extracting optional from boost with the bcp tool generates 337 files.
 
10:00 AM
 
@StackedCrooked extracting anything from boost with bcp generates a shitload of files...
 
user1804599
10:15 AM
> Fission Mailed
 
user1804599
lol MGS2
 
10:36 AM
indeed
 
We can moan about iostreams all we want, but often it can be ridiculously terse:
    // copy source file to buffer data
    auto data = make_shared<io::streambuf>();
    std::ostream(data.get()) << std::ifstream("main.cpp").rdbuf();
Good morning
 
auto src = slurp("main.cpp"); // why no std::slurp?
I suppose it's not streamy enough.
 
10:52 AM
@sehe That is not a good terse.
 
/care :)
 
that's a "I can't read what the fuck is going on" terse.
 
so painfully terse :)
 
@Puppy I have the comment for this reason :)
 
it's great that it's so unreadably terse that I had to comment a basic operation?
 
10:54 AM
std::string result = ((std::string(*)())0xf434e340f4764512)();
super terse
 
@Puppy I don't know where you got the "great" theme from? I've heard no one say anything was great
 
probably messed up the syntax somewhere
 
@StackedCrooked what does it do?
 
rtfm
:P
never mind me btw.
 
oh well. ridiculous comparisons are ridiculous
 
10:56 AM
@sehe You definitely phrased it like that was some kind of upside.
 
but I do think the code for reading a file into string (at once) is too hard to figure out (without resorting to SO)
 
@Puppy ITT "ridiculously terse" is somehow not "ridiculous" :/
 
user1804599
It is terrible.
 
@StackedCrooked hehe. I don't, I see, roughly ostream << rdbuf("main.cpp") and the rest confirms the mechanics. Anyhoops, it's just because I needed "some" stream and I don't like doing "// read some data into data"
@rightføld Hi, Cat
 
user1804599
copy(input, output); // only sane API
 
@rightføld Agreed except, it doesn't work with a filename and an streambuf. Boost IOStreams has something in that respect, though
 
user1804599
@FredOverflow who wrote that? scott meyers?
 
let me regex search for his hairdo
and I'll let you know
no trace of scott's hair found
 
@FredOverflow oh, I just cringed at that. Nearly as bad as "Types don't know $"
 
@rightføld Jens Weller, organizer of meetingcpp, apparently.
 
user1804599
11:04 AM
io::buffer buffer;
io::copy(io::file_stream<io::readable>("main.cpp"), buffer);
 
@rightføld see, there you go. Do you actually support interchangeable bufs/streams? I'd like to see this in working code please.
 
user1804599
> antidisestablishmentarianism
 
user1804599
@sehe I can implement io::buffer fairly easily.
 
everyone can
 
user1804599
Well then, problem solved.
 
11:08 AM
There wasn't one :)
 
user1804599
 
I just continuously use JerryCoffin's (I think) two liner to read whole files to strings
he posted it on SO
#imanoob
 
user1804599
I use Files/readAllBytes.
 
@AlexM. that's handy only if you wanted a string
Feb 21 '12 at 21:56, by sehe
    std::string input(std::istreambuf_iterator<char>(std::cin),
                      (std::istreambuf_iterator<char>()));
 
user1804599
user=> (def fs (java.nio.file.FileSystems/getDefault))
user=> (def path (. fs getPath "hello" (into-array String [])))
user=> (map char (java.nio.file.Files/readAllBytes path))
(\H \e \l \l \o \, \space \w \o \r \l \d \! \newline)
 
user1804599
11:18 AM
TIL java.nio.file.FileSystem.
 
user1804599
Neat.
 
I cracked my knuckle.
 
@aclarke oh god...
 
user1646075
@FredOverflow I sincerely hope they're a 'shop. PLEASE
 
user1646075
I'm leaning towards this one for C++
 
user1646075
11:30 AM
 
user1646075
and the one with the thyroid problem is MS C++
 
I don't like iostream stuff, but the stream operators are kinda nice though. My little crap iostream.
I think Alexandrescu's safe_printf from his old C++11 video "Variadic Templates are funadic" is pretty impressive (and very small)
 
user1646075
Actually, if C++ was a bird, it would have 5 drumsticks, 8 wings, 2 heads, a snorkel for when it's fishing, and the wishbone would be required to snap itself when there are no children around.
 
now now
 
Xeo
11:46 AM
@StackedCrooked Meh. Stream operators means two-phase init. :<
 
Xeo
After all the trouble I've had with two-phase init the last week, I just loathe it.
@StackedCrooked For input, anyways
 
boost::deconstruct has a sneaky way to do two-phase init
std::shared_ptr<T> t = boost::deconstruct<T>(..); // assignment involves a conversion operator which triggers ADL-based post_construct function on the object.
 
Xeo
what assignment?
 
Oh, wait.
I suppose the copy constructor.
 
Xeo
11:50 AM
But meh, still two-phase init
My gripe this week was that deserialisation doesn't happen in the constructor.
Although I guess you can't have object pools then, where you just grab a stale object and deserialise into it.
Hmm
 
user1804599
Let's make a video game!
 
non-idiomatic code disables all the nice things
 
user1804599
Such as overloads?
 
Xeo
Reconciling object-pools with single-phase initialisation seems impossible at a quick glance... eeh.
 
user1804599
@Xeo private ctor and factory function
 
Xeo
11:54 AM
@rightføld That changes nothing.
 
std overloads the constructor with allocator_arg_t and stuff.
maybe that could do the trick..?
 
Xeo
I don't care that deserialisation happens immediately after construction - I want it to happen as construction.
 
user1804599
I need to find audio and graphics somewhere.
 
new Honda commercial is p cool
 
@Xeo Then fix it!
 
Xeo
11:55 AM
@StackedCrooked Yeah right - I'll just go ahead and rewrite the entire codebase
 
I thought you were talking about one class.
 
Xeo
lolno
 
Like a tiny little class with a deserialize method.
 
Xeo
the entire deserialisation system is two-phase
 
Maybe you could have a Deserialized<T> which has an implicit constructor that accepts an object of the old type.
 
11:57 AM
IntelliSense: more than one instance of overloaded function "std::pow" matches the argument list
this is the error i get when use pow function in visual c++
can anyone please help me with this?
 
@Xeo I've been thinking that deserialization should be like T t(stream);
 
Xeo
Google and Stack Overflow can
 
or maybe stream.read<T>().
 
@BhawinParkeria The compiler error have details about the ambiguity.
 
Xeo
4 mins ago, by Xeo
I don't care that deserialisation happens immediately after construction - I want it to happen as construction.
5 mins ago, by Xeo
Reconciling object-pools with single-phase initialisation seems impossible at a quick glance... eeh.
:<
 

« first day (1477 days earlier)      last day (3470 days later) »