Lounge<C++>

Today we're daydreaming about C++26 reflection
Nov 13, 2013 21:06
lol
Nov 13, 2013 20:57
@R.MartinhoFernandes I think I figured out the correct solution to the callback think we talked about earlier
Nov 13, 2013 18:02
:)
Nov 13, 2013 18:00
@R.MartinhoFernandes how about one overload with a function pointer + void* and another with std::function?
Nov 13, 2013 17:59
yes, it's an ABI boundary
Nov 13, 2013 17:58
anyway, I gotta leave now. see you later
Nov 13, 2013 17:57
true
Nov 13, 2013 17:57
ah
Nov 13, 2013 17:56
how about providing an overload which accepts a function pointer and another overload that accepts an std::function?
Nov 13, 2013 17:55
yes, that also matters
Nov 13, 2013 17:54
@Xeo putting the whole implementation in a header sucks even more
Nov 13, 2013 17:50
anyway, if I don't care about capturing lamdbas, function pointers will work fine, too
Nov 13, 2013 17:49
well, that's one way of doing it
Nov 13, 2013 17:48
heh
Nov 13, 2013 17:47
yes, but putting that code in the header will expose all the implementation details (such as the private class, etc)
Nov 13, 2013 17:45
I don't want to put the implementation details into a header
Nov 13, 2013 17:44
well, the template thing works, but it stops working if I don't want to put the function body in the header
Nov 13, 2013 17:42
hm
Nov 13, 2013 17:38
ah, so it's basically irrelevant to my question
Nov 13, 2013 17:34
@R.MartinhoFernandes found it on cppreference
Nov 13, 2013 17:34
@R.MartinhoFernandes nice! what is std::bind?
Nov 13, 2013 17:32
I'm interested in how to do this correctly, but didn't find many alternatives
Nov 13, 2013 17:29
@R.MartinhoFernandes can you point me to some article about this?
Nov 13, 2013 17:26
@R.MartinhoFernandes what are the drawbacks?
Nov 13, 2013 17:26
@R.MartinhoFernandes without templates, in a way that one can pass in a capturing lamba
Nov 13, 2013 17:24
I see, but then, how do you do this without templates?
Nov 13, 2013 17:22
btw, I see std::function as a sort of smart pointer for functions
Nov 13, 2013 17:20
if you use templates like that, don't you have to put the function body into a header file?
Nov 13, 2013 17:19
templates are not going to cut it
Nov 13, 2013 17:18
@Xeo @R.MartinhoFernandes the trouble is that function pointers don't work with capturing lambdas
Nov 13, 2013 17:17
@R.MartinhoFernandes it's just a reference to the container, not the container itself
Nov 13, 2013 17:16
@Xeo why not do_stuff_async(const std::function &callback)?
Nov 13, 2013 17:13
@Xeo let's say you write a method that does something asynchronously and you want it to call a function when it's done. for this I could use a function pointer but the trouble with function pointers is that you can't squeeze capturing lambdas in them
Nov 13, 2013 17:10
in situations when you want a callback, for example
Nov 13, 2013 17:10
but is it ok to pass it as const reference?
Nov 13, 2013 17:09
@Xeo why not?
Nov 13, 2013 17:08
when using std::function, should I pass it around as const reference?
Nov 13, 2013 16:42
no wonder people are bad at it, this kind of thinking is not taught at school
Nov 13, 2013 16:40
You've just gained a follower for the rule of zero :)
Nov 13, 2013 16:40
Great
Nov 13, 2013 16:40
@R.MartinhoFernandes Ah I see, so those two things are parameters for the unique_ptr constructor, right?
Nov 13, 2013 16:33
@R.MartinhoFernandes how about this line?
handle { ::LoadLibrary(name.c_str()), &::FreeLibrary }
when is &::FreeLibrary called in this case?
Nov 13, 2013 16:30
@R.MartinhoFernandes I'm reading your article rule of zero, but I don't think I've seen the syntax you use for initializing members. Is that a new C++11 feature?
Nov 12, 2013 20:12
@R.MartinhoFernandes thanks! The thing is, I haven't quite decided what to use yet and am still looking around. I also don't mind being an alpha tester sometimes
Nov 12, 2013 20:11
@r.
Nov 12, 2013 20:09
@R.MartinhoFernandes I see. :) I'm quite curious about it, are there API docs yet?
Nov 12, 2013 20:05
@R.MartinhoFernandes would you recommend using Ogonek instead of ICU?
Nov 12, 2013 20:01
hey