« first day (563 days earlier)      last day (4389 days later) » 

8:00 PM
Rule of thumb: pointers bad.
 
Obj1 would be the base
 
@user908041 pointer then
 
Ooh, nasty then.
Slicing an shit.
 
what the
conflicting advice here lol
 
@user908041 you should have said it was a polymorphic type
that changes things
 
8:00 PM
oh right
 
@user908041 never make a copy when base classes are involved. ALways pointer when base classes are involved.
 
now you need to return a unique_ptr<Obj>
 
84
Q: What is the slicing problem in C++?

FrankomaniaSomeone mentioned it in the IRC, but google doesn't have a good answer.

 
unique_ptrs to Derived are convertible to unique_ptrs to Base, correct?
 
8:02 PM
whaaaaaat
only I'm allowed to say those words
 
They may be movable into unique_ptrs to Base. Don't know if you want to call that convertible.
 
ok
A "Developer preview" is expected to be less developed than a "Beta" right?
 
right so I'd actually be using Obj1 obj* = myclass.getActiveInstance(); ? where it returns unique_ptrs
 
@user908041 does that function create a new Obj1?
or does it return a pointer to one that exists elsewhere
 
Don't return pointers to local variables.
@SethCarnegie Yeah.
 
8:05 PM
elsewhere being also elsewhere than on the stack of the function
 
@Seth it would return the active instance of Obj1 in myclass
or if it is null then it'd create a new object
 
Given std::unique_ptr<T> x;, you can do std::unique_ptr<U> y(std::move(x)); as long as T* a; U* b = a; compiles.
 
@user908041 then it would return weak_ptr<Obj1>, not unique_ptr<Obj1>
 
@user908041 then you want either native pointer or weak pointer, since you don't have ownership
 
@MooingDuck weak_ptr is for this situation right
 
8:06 PM
Oh gawd a singleton
 
@SethCarnegie No (and I say that not know exactly what the situation is).
 
@SethCarnegie only if it's a shared_ptr
 
well this is destroying my brain a little
 
@MooingDuck so then what about plain non-owning ponters
pointers*
 
@SethCarnegie Type*
 
8:07 PM
Wait I thought we had abandoned raw pointers
 
@SethCarnegie non-owning pointers don't need to be smart
 
How do you know who owns it? and all that jazz
 
@SethCarnegie you could make a "smart" pointer for non owning to be clear, but none is standard
 
For what is worth it sound to me like the correct answer is to return a reference.
 
@SethCarnegie if you don't own it, you don't need a smart pointer
 
8:08 PM
Yeah.
 
I'm not saying that just to sow more confusion.
 
@RMartinhoFernandes yeah that would be best I think
 
And then delete all of that code and stop using singletons.
 
@RMartinhoFernandes oh, yeah, if it can't return NULL, then do that.
 
@user908041 it's decided, return a reference :)
 
8:09 PM
@SethCarnegie I think we scared him away. Or melted him.
 
lol ok @SethCarnegie well I'm just paste binning something to get this cleared up properly
@MooingDuck melted
 
Hey, I'm the robot here. I'm the only one allowed to melt people.
 
My brain will melt itself with a moments notice
 
This is the difference between Microsoft and Apple
Microsoft can't even make an icon where one side isn't chopped off
 
Ell
stupid virtual machine! :@ why x crash?
 
8:13 PM
The installer is pretty though
I don't know why Microsoft itself writes programs that don't use the native GUI controls though
 
Ell
because they aren't good enough?
 
Because they want to M$ify everything.
 
@Mysticial it's Windows, everything is already M$ified
 
What type of GUI controls are you talking about?
 
Right, sorry for the delay. Anyway, here is in general what I was trying to do -> pastie.org/private/mwfffo90qd4nsdbq97jw
however, I wrote that quick and I'm new to C++ so half of that probably isn't even C++
but it should get my POINT across :> (see what I did there?)
 
8:18 PM
you want a Singleton
the most disgusting design pattern ever
I could, but won't, help you build something so terrible
 
lol
 
Ell
why do you need a singleton?
 
I appreciate your sentiment
I was thinking more about the use of pointers and less about the methodology of what I was actually trying to carry out
 
@RMartinhoFernandes we're still not sure what the problem was, but apparently it came about by mixing Dinkum's library with STLPort.
 
Because Visual C++ is dumb. — Seth Carnegie 31 secs ago
lol
 
8:20 PM
But you won't say I'm wrong
 
That's not really a singleton. It doesn't prevent one from creating Obj2 instances.
 
this.myObj?
 
What I was trying to achieve there was just to have 1 active object which could be used lots of times without recreating it over and over
 
also missing return types
what is this code
 
@SethCarnegie read what I said when i posted the pe
paste*
 
8:22 PM
oh, so horrible means "won't compile"
ok
 
"I wrote that quick and I'm new to C++ so half of that probably isn't even C++"
i wrote it in pastie, I never tried to make it work
 
@user908041 the return type should be Obj2&, and you should return *this->myObj if you are doing this->myObj = new Obj2
 
@Ell still wrong
 
Ell
I'm newb too :L
oops
 
8:23 PM
assuming null is defined
 
no lol
 
However I am concerned that @DeadMg thought my methodology was horrific.
 
brb rebooting
 
@SethCarnegie MyClass::getActiveInstance() has no return type
 
Ell
8:25 PM
@SethCarnegie missing return type on get active instance :L
 
Rule #1 of learning C++: if you know C, Java or C#, forget about it.
 
@MooingDuck I thought someone else fixed that
 
@user908041 he says that about everyone elsees code, no worries
 
Ell
damn mine are mismatched :L meh I can't code :P
 
@user908041 he's just saying don't write classes that only allow one instance to be in existance
 
8:25 PM
@Ell no, he wants to return by reference
 
@RMartinhoFernandes Just so happens my strongest language is Java
@SethCarnegie well, essentially i was just trying to have 1 object in existance and access it throughout my application
 
Ell
must have got it this time pastie.org/private/utkpnrwcunbppx7uebcig
 
I thought that would be the best thing to do
 
@user908041 it's ok to only have one instance. It's not ok if the type enforces that.
 
Obj& gimme_the_object() {
    static Obj obj;
    return obj;
} // look ma, no weird classes
 
8:27 PM
well no, it doesn't enforce that @MooingDuck :P
 
Ell
@RMartinhoFernandes ...you can do that? :O
 
@Ell yes
 
Ell
woaah I never use static variables inside function bodies like that... looks like magic to me :o
 
@Ell static variables are magic, yes :D
and very handy
 
surely that would return null, as static Obj obj; is never assigned a value?
 
8:29 PM
Remember that thing I said about forgetting Java?
 
@user908041 it's a local object, it's default constructed on first use
 
This is not Java!
 
lol
/me brain implodes
 
Ell
@user908041 awesome thing c++, right?
 
yes
 
Ell
8:30 PM
even better than c++--
 
The only reason I started learning Java was because of Android
 
0
A: Support in vim for specific types of comments

seheFirst of all, get to know the features that make life easier for stuff like this in vim: Visual block mode blockwise-visual blockwise operators virtualedit; You can move the cursor to positions where there isn't any text. This is called "virtual space". The user guide has extensive samples ...

 
@Ell careful, C-- is a real thing
 
Someone upvoted my comment at the OP but didn't like my answer...
 
@MooingDuck, surely C++-- defaults to C?
 
Ell
8:31 PM
@MooingDuck really? i will google :L
yeah c++-- was meant to be c :L
 
Or, on the bright side, someone is trying all that stuff ^^ out and it is taking a while.
It was taking a while :)
 
@user908041 getting C++ to run on Android is harder I hear :/
 
@MooingDuck and a waste of time
 
I never said that's why I'm learning C++
 
we never thought you did
 
8:33 PM
@user908041 that's why you're learning it
there, I said it
 
Once again I spent oodles of time on the wrong questions. I might even repcap today, but I wasted a lot of time on that shady vim question (and of course, the Spirit user list).
 
@sehe For once, you take too much effort for an answer on a topic I understand, so I can +1.
 
I have much more rep so we all know the truth now
 
lol, but @SethCarnegie why is it a waste of time?
just out of curiosity
 
You're flattering me
I think
Let me see what I can repwhore
 
8:34 PM
@user908041 it takes too much code to do the simplest things because you don't have everything prewritten
like GUI for example
 
@sehe you use spirit?
 
Oh GUI I would agree on, no doubt.
 
@stdOrgnlDave I do. (Why?)
 
@SethCarnegie Haven't they made a way for the C/C++ to use the Java libraries? I figured someone would have done that by now.
 
@MooingDuck JNI or something
I heard it was junk but I don't have proof or references
 
8:35 PM
@sehe I bow down before you, oh God of implementing from incomprehensible documentation and implementation. well, that's assuming Spirit is like the rest of Boost, except 10x more complicated.
 
@SethCarnegie Oh, I meant Android/other specific C++ wrappers around JNI
 
You know, I feel left out.
 
If I was to use C++ on android, it'd either be for portable back-end code, or for a game using Cocos2d-x
 
@MooingDuck let me know if there is one
 
Sometimes it sounds like I'm the only one that can't find the incomprehensible documentation of boost.
 
8:36 PM
@stdOrgnlDave It is becoming quite a turn off to me too. But I still like the concept and with some 'critical mass' of experience you can really be agile with it.
 
I've looked in many places, but I haven't seen it yet.
 
I would love to write stuff for Android but I do not want to learn Java
 
But I do have my annoyances with Spirit which I (cleverly?) avoid :)
 
There's NDK.
 
@SethCarnegie me too :(
 
8:37 PM
@sehe to me, Spirit has always been that dirty part of Boost you don't touch, like a butthole
 
I've seen a book called Thinking in Java
sounds like a disease to me
 
Java can be learned in 20 minutes.
I know I did.
 
I had a problem, so I thought to use Java. Now I have a ProblemFactory
 
@SethCarnegie It's from the author of Thinking in C++ (and that one is on The List), btw.
 
There isn't much to it.
 
8:37 PM
@stdOrgnlDave Mmm. Boost Meta State Machines is that for me
 
@RMartinhoFernandes he obviously wrote Java second
 
Ell
It seems to me java is easy - everything is straightforward (apart from generics for me) but it's probably not?
 
which do you think is more damaging to beginning programmers: BASIC or Java? battle commence!
 
@Ell Right, it’s not. Java has some … interesting caveats
 
8:39 PM
@SethCarnegie Nope.
 
Generics are as easy and primitive as the rest of it.
 
NullPointerException being my (new) favorite Java fun
 
@RMartinhoFernandes wow, then I'll make sure not to read either of them lol
 
TIC++ is fairly good, AFAIK.
 
8:40 PM
@CatPlusPlus looks like you need to go through JNI for GUI stuff outside of OpenGL or Pixel buffer access.
 
Dunno.
 
I feel bad for the Boost guys, now that C++11 is rolling out, half the library is going to be obsolete and the other half is going to need extensive rewrites. by 2018 when we get a compiler that implements C++11 properly they may have it done, though.
7
 
I only have to write three Android things for embedded systems class and then I'm done with that.
I have no interest in mobile platforms whatsoever.
 
@stdOrgnlDave +1
 
Half of C++11 is from Boost.
4
 
8:41 PM
@CatPlusPlus that's probably where it's all going though
 
@CatPlusPlus mobile platforms or embedded platforms?
 
@CatPlusPlus that's the point
 
@SethCarnegie Yeah, right.
5 years ago it was WEB 2.0 ALL THE THINGS and Chrome OS and shit.
Now it's mobile. 5 years from now it'll be something else.
 
Maybe
 
so what you're saying is, you're cool with embedded systems, but not mobile ones
 
8:43 PM
And desktops will keep looking and shrugging it off.
 
by the way we're chatting in a web2.0 chat room
 
@stdOrgnlDave I don't care for either.
Web is painful enough. Hell, even the big desktop three.
 
@CatPlusPlus what you need is an abstract turing machine that takes C++ as native syntax. then you'll be happy, eh?
 
At least I can debug web/desktop things without the need for emulator so slow it actually bends time.
 
8:44 PM
I prefer Haskell.
 
why does g++ complain about unresolved reference to create function?
 
Can you use Haskell on mobile? Not really. So not interested.
 
yeah what's up with the android emulator? srsly my computer can run PowerPC wii games
 
@CheersandhthAlf is the ! character on your 4 key?
 
8:45 PM
no, it's just a loose laptop
laptop on the loose
 
@stdOrgnlDave It sucks. 'nuff said.
 
[d:\dev\test]
> g++ foo.cpp -std=c++0x
C:\Users\Alf\AppData\Local\Temp\ccznfrem.o:foo.cpp:(.text+0x154): undefined reference to `std::unique_ptr<Blah, std::def
ault_delete<Blah> > create<Blah>(char const*)'
collect2: ld returned 1 exit status

[d:\dev\test]
>
 
@stdOrgnlDave It sucks so much many devs prefer to use actual devices.
 
it's g++ 4.6.1
 
The emulator is delegated to test with various resolutions.
 
8:48 PM
maybe it's obvious but i am a bit unwell and i was going to post a correction to comp.std.c++
 
you know the #1 thing I would've liked in the C++11 standards? mandatory sensical template errors for STL-type built-ins. like, they copyright "C++11" and then give free licenses when a simple std::vector instantiation error doesn't give 500 lines of useless errors
 
but difficult when darned code will not compile
 
@CheersandhthAlf how is shared_ptr supposed to delete a class with a protected destructor?
 
test.c++: In copy constructor 'Blah::Blah(const Blah&)':
test.c++:22:5: error: base class 'class std::enable_shared_from_this<Blah>' should be explicitly initialized in the copy constructor [-Werror=extra]
 
@SethCarnegie oh that works fine. it uses std::default_delete, which it gets from unique_ptr
 
8:49 PM
@CheersandhthAlf This is what 4.7 gives me.
 
@CheersandhthAlf so they can use protected destructors? I didn't know that
 
nhg, thanks! Ill try that!
@SethCarnegie only when you tell'em to! look at the friend declarations
 
@CheersandhthAlf how?
Oh
 
test.c++:8:32: fatal error: 'operator new' is a protected member of 'Blah'
Clang doesn't like it.
 
Well as far as pointers go I'm clued up a tad more now, however going back to the previously discussed source, I don't understand how getActiveInstance() should return Obj2& - Obj1 obj = class.getActiveInstance() will just return an address in memory? Or have I got that all wrong?
Jesus I read up on pointers, thought it makes sense, then when I try to apply them it all goes to crap.
 
8:52 PM
Do you have a book?
 
yes
 
@user908041 it should be Obj1& obj, not Obj1 obj
 
^ it still complains about unresolved refernece
 
@user908041 you want getActiveInstance() to return a reference not a pointer
 
8:53 PM
I wonder how much havok I could wreak by passing a lambda with local imports into an std::async
 
clang is wrong ;-)
 
I am willing to bet that no current compilers will handle that gracefully
 
@stdOrgnlDave imports?
 
morning
 
@CheersandhthAlf Yeah, same here now.
Makes no sense.
 
8:54 PM
i must get it to work, then change create function to make_unique class
 
@CheersandhthAlf and it works when you take the arguments away from the call to create
 
@seth: you mean with default construction?
 
@MooingDuck well the latest paste pastie.org/private/utkpnrwcunbppx7uebcig (line 11 is seemingly incorrect)
 
@CheersandhthAlf also works with passing an integer
instead of a string
 
8:55 PM
Hmm, shouldn't create<Blah>( "blah" ) instantiate for char const(&)[5] not char const*?
 
oh my friend declaration is messed up
old
i did not update it
i'm stupid
 
The only thing that's not working for me is passing a string to create
lol
 
@RMartinhoFernandes I have several books, in fact :)
 
@SethCarnegie int x = 2; auto p = [&] { x = 4; }; auto h = std::async(std::launch::async,p); // the [&] is the default import type
 
@user908041 You need to read up on the difference between pointers and references.
 
8:57 PM
hurray! works!
thanks everyone
 
@RMartinhoFernandes for a second I was like what...
 
@stdOrgnlDave You mean captures?
 
i'll post the code just for
 
@stdOrgnlDave ah, I wasn't aware that was what those were called
 
@RMartinhoFernandes yes, captures! thanks
@SethCarnegie it's captures, @RMartinhoFernandes corrected me
 
ah
VS 11 beta takes forever to install
 
@CheersandhthAlf compiles in clang as well now.
 
now i'll just change that function to a properly named proper class...
 
boo ya!
reddit frontpage
 
aha, reading now @RMartinhoFernandes
 
8:59 PM
my work here is done
 

« first day (563 days earlier)      last day (4389 days later) »