« first day (1355 days earlier)      last day (3592 days later) » 

user3010322
5:00 AM
@StackedCrooked Compile-time introspection to resolve function types.
 
user3010322
And to make it so you can resolve it without neck-breaking static_casts
 
user3010322
So you can do...
 
user3010322
call( Functor{} ); // works if not overloaded
call<int>( OverloadedFunc ); // calls version with 1 int parameter
call<int, int>( OverloadedFunc ); // calls version with 2 int parameters
call<void( int )>( OverloadedFunc ); // calls version with exact signature: same call<int> for overloaded item
 
._.
 
Xeo
5:02 AM
^ how to use the has_deducible_signature
 
user3010322
template<class... Args, class R>
void set( R (&fun_ptr)( Args... ) ) {
    std::cout << "Function reference, argumented\n";
}

template<class Sig>
void set( Sig& fun_ptr ) {
    std::cout << "Function reference, signatured\n";
}
 
user3010322
@Xeo ^ Adding these two actually makes compilation fail in that it can't figure out between function pointer and the reference one which to use
 
Xeo
You don't need to handle function references btw
just use function pointers
 
user3010322
Yeah...
 
user3010322
But I like function references. ;~;
 
Xeo
5:06 AM
Eh
they're not very special / useful
 
user3010322
It's... cool. :D
 
Xeo
since you can call function pointers like normal functions too
also, I noticed that Clang doesn't seem to like the deduced R for (member) function pointers
 
user3010322
Well clang can go suck a duck
 
user3010322
In either case, I'm having a hard time making function_traits automagically attempt to use has_deducible_signature on the FuncSignature template parameter to check if its a functor and then provide the function_traits if it is.
 
Xeo
...
 
5:09 AM
Jesus dude
 
user3010322
Don't jesus me. D:
 
user3010322
It's the partial templatey bits that are giving me a hard time!
 
I thought I'd be making it easier on myself trying to put this little app together in msvc++ 2012 sans a big framework using simpler stuff as i'm no C++ dev. So wrong. The meddling to get boost working so I could use asio for the networking and looking at it's examples, it's so much easier to follow...
 
user3010322
Like, it has a base signature of template <typename Sig> right now.
 
user3010322
And has lots of template specializations
 
Xeo
5:11 AM
template<class T, bool = some_trait<T>::value>
struct my_trait{};

template<class T>
struct my_trait<T, true> : my_real_trait<T>{};
^ there, something else to play around with
 
user3010322
... Huh.
 
Given that I think I might try my hand at a modern c++ book seeing the modern stuff is much easier to make out
 
user3010322
If I change that to false, I can make it work I think.
 
Xeo
... wat. Didn't you want to provide it in case has_deducible_signature is true?
just put whatever you have currently in a detail namespace, and then put what I wrote there at top-level and dispatch to the detail stuff
 
Might not be so painful to get the basics that way as opposed to my usual learning approach of references and interactive exploration seeing as the syntax is so unbelievably inconsistent compared to other languages
What from the SO c++ canonical book list is best for picking up the syntax and basic stuff from the standard library without doing anything in older style? The modern x11 code I've seen is actually really easy to follow, like the anonymous closure syntax
Is it terribly bad practice to collate all my classes in one file so I don't have to separate the interface and implementation just to use includes since the compiler doesn't collate it all for me? (in a small program, no shared components outside the exe)
 
user3010322
5:23 AM
@Xeo It's... it's beautiful.
 
Xeo
ugh, indented namespace content
 
user3010322
I'm going to make this into an official function. I'll call it resolve. It will return a function of some time -- member function pointer, function pointer, member variable pointer, etc.
 
user3010322
So I can use it like std::stuff( meowbegin, meowend, resolve<int>( titties ) )
 
Xeo
@ThePhD also, you can assume either false or true as the default
also, you suck, now you get non_functor_function_traits<T> with functors that are not deducible
 
user3010322
Which will fail to compile completely.
 
Xeo
5:25 AM
yes, with a horrible hard error
 
user3010322
Fine, I'll stick a static_assert in the default impl
 
Xeo
oh no wait
tis fine
 
user3010322
NOPE
 
Xeo
I forgot you had an empty default impl
 
user3010322
STATIC-ASSERT
 
Xeo
5:26 AM
you want a soft error, not a hard error
 
user3010322
:(
 
user3010322
Fine.
 
user3010322
Should I add a case for regular pointers?
 
Xeo
vOv
 
user3010322
Doesn't Sig* funptr technically cover it?
 
Xeo
5:27 AM
hm, 7:30. I might just go to work.
@ThePhD yes
not like you need to resolve (member) object pointers anyways
 
user3010322
Guess they'll just eat the shit with `Sig* funptr then.
 
i just noticed my code contains the line _el(o._el)
great work all around
 
5:41 AM
Whenever I bring up VS' suckage on reddit I get people defending it
:<
 
Xeo
1 message moved to I can't type
 
user3010322
:(((
 
user3010322
y u do dis
 
Xeo
Well someone has to at least try to educate you.
 
So @ThePhD are you going to be my sensei?!
 
user3010322
5:45 AM
Dude, I'm fucking terrible. How can I be your sensei?
 
I know
 
user3010322
Ask Xeo. He's actually had classes on this stuff!
 
But you can try
 
Xeo
classes on what?
 
Game design I think
 
Xeo
5:46 AM
@Rapptz VS is still refusing to correctly highlight that one file. :< As soon as I don't have unbalanced braces / parens, it stops.
it's so fucking broken
 
this is bugging me
it's been bugging me for 3 days
Why is that string literal not highlighted ._.
 
@Xeo You had classes on game design?
Lucky boy.
 
Xeo
Not really
we were a programmer course, not a designer course
 
0
Q: Can anybody explain this wired C++ code piece?

user3796257#define WIRED\ []() {\ return new MyClass; \ }() MyClass* a = WIRED; I don't understand the first "" and the last "()" in the MACRO. Can any expert explain this? Thanks.

What a fucking useless lambda and macro.
Holy shit
 
user3010322
R( unqualified_t<F>::*resolve_i )( Args... ) ( types<R( Args... )>, F&& f )
 
user3010322
5:50 AM
Apparently, this is not legal in the slightest.
 
user3010322
How do I return a function from a function?
 
Xeo
you mean function pointer
you can't return functions
 
user3010322
Well, yes.
 
user3010322
The point is I can't... return it.
 
Xeo
use an alias
 
user3010322
5:52 AM
Or, at lest
 
user3010322
I don't know the name
 
Xeo
the syntax is horrible
Alias<R (unqualified_t<F>::*)(Args...)> resolve_i(...);
trailing-return works too
 
user3010322
Arrrf
 
user3010322
It's not working. :c
 
Xeo
auto resolve_i(...) -> R (unqualified_t<F>::*)(Args...)
 
user3010322
6:00 AM
Hm.
 
user3010322
Neither syntax is working at all..
 
Xeo
maybe the unqualified_t<F> is throwing it off, who knows
off to work
 
user3010322
Progress marker for later I guess: coliru.stacked-crooked.com/a/3c5ab6bb991e5ff1
 
Xeo
6:28 AM
Looking closely at the error helps, btw
 
0xE2 0x99 0xBB..
@ThePhD why'd you pick this :v
 
@Xeo dat edit :)
 
Btw @Xeo I was thinking about your static_cast suggestion from a few days back and I looked into it today and realised that dynamic_cast is apparently pretty slow, for some definitions of slow anyway.
 
Xeo
teehee
 
does std::is_base_of use compiler magic?
 
Xeo
6:42 AM
it's possible without compiler-magic
needs some template-magic though
IIRC
At least Boost has some magic for their non-compiler-supported is_base_of
 
62
Q: How does `is_base_of` work?

Alexey MalistovHow does the following code work? typedef char (&yes)[1]; typedef char (&no)[2]; template <typename B, typename D> struct Host { operator B*() const; operator D*(); }; template <typename B, typename D> struct is_base_of { template <typename T> static yes check(D*, T); static no chec...

All ideone links from < 2011 are broken lol
 
Xeo
yeah :<
 
So I read the accepted answer to that
I don't think I get it
I don't understand where he gets these D* (Host<B, D>&) functions from? I don't seem them in the question?
 
It's just his way of illustrating candidates
Host<B, D> is the parameter to check
D* is the result he's walking you through
 
Xeo
@TonyTheLion They're synthesised.
from the conversion functions in Host
 
6:58 AM
oh, the compiler synthesizes them, or Johannes just did as an example?
 
Xeo
both, likely
it's just overload resolution, really
 
one does not simply, overload resolution
 
Xeo
and that needs a signature
 
I tried to understand overload resolution once, I still have nightmares :P
 
Xeo
heh
 
7:05 AM
TIL there's no place on the web that has a contiguous list of all (visible) ascii characters that I can copy.
 
@MarkGarcia How do you expect to copy <= 0x1f?
Those are control characters
 
Could someone please tell me why an assert_false equivalent is not ok for unit testings but assert_true is?
 
user1804599
@Rapptz He asked specifically for copyable, visible ASCII characters.
 
user1804599
 
user1804599
Oh god.
 
7:11 AM
then why doesn't he write it himself? :v
 
Morning guys
 
Morning.
 
Quick question: am I right here?
@user3793540 ah yes, you're passing the structure. I would dare to say this is undefined behaviour because there may be padding added to the struct which you are ignoring. — rubenvb 36 secs ago
 
Good morning.
@Rapptz I actually meant the ISO-88something charset. With 128-255.
 
that's not ASCII
 
7:12 AM
Which coliru doesn't support displaying (I tried).
@Rapptz Yeah, yeah.
 
Xeo
everything a distribution needs to be "cloned"
or rather, re-initialised from the starting params
 
I'm looking for a way to reset the b parameter
this looked promising but documentation is kinda scarce
it tells me param_type is unspecified so it's not helpful :v
 
Xeo
heh
 
user1804599
> As of 2017, companies that do not employ enough people with a disability, risk a fine of 5,000 euros per non-completed position.
 
user1804599
This is worse than MORE FEMALE PROGRAMMERS OR ELSE.
 
why can't I just set it normally like a decent human being
:(
 
user1804599
Because you suck.
 
Heloo people :)
 
hi
 
7:24 AM
I am junior dev unsing a lot of C++ am I in the right place ?
 
main.cpp:9:22: error: converting to 'const std::uniform_int_distribution<>::param_type' from initializer list would use explicit constructor 'std::uniform_int_distribution<_IntType>::param_type::param_type(_IntType, _IntType) [with _IntType = int]'
     dis.param({1, 10});
                      ^
booooo
:(
also wow that error is surprisingly long winded
 
@Rapptz code or it didn't happen
ah wait
I can get at it
lol
 
249 columns
 
Anyways: typedef /*unspecified*/ param_type;
That's why.
 
I have to do decltype(dis)::param_type{1, 10}
I just wanted to shorten it
 
7:28 AM
The effect of that is unspecified
because the type is unspecified
So you really can't do that.
The reason that function is there is to set params from another instance of the same type of distribution, without having to copy it all.
 
I know what it's for and I know it's unspecified (scroll up)
but I'm not making another distribution just to set the a/b parameters
that's retarded
 
Apparently it's the only way.
Or ask on SO
@Rapptz This question may already have an answer here.
 
Yeah. That is where I got the idea from.
 
He's telling you not to do it.
And then says you can do some unspecified mumbo-jumbo
 
oooh, monthly phone 'bill' is here...
@MartinJames any guesses?
 
7:34 AM
He's ranting :v
Honestly it's a bad answer
It's specified in boost
I don't know why it's unspecified in C++ standard
But boost has it specified
it's all over its docs
 
So it is. Downvotes incoming.
 
huh, that was actually amazingly cheap... like cheap enough you could pay it yourself
... what year is it?
 
I'm very confused
They have a/b and min/max
two member functions that do the same exact thing
 
@Rapptz That's great stuff!
 
might be for generic programming iunno
 
7:38 AM
C++11 doesn't have min/max though.
 
I meant maybe it's for consistency for every other distribution
 
Then it should have lost its a/b. Really
If the parameters don't convey min/max, then generic programming with them would be pointless.
 
I feel like leaving param_type as unspecified really messed things up
 
Xeo
:D
or just dis = {dis.a(), 10};
 
so bad
 
Xeo
7:41 AM
they have copy ctors, right?
 
:(
 
@Rapptz I really think you're overcomplicating this. Just create a new distribution.
 
doesn't seem to be explicit
 
Sheesh.
 
@rubenvb It's a static instance
it'd be weird
 
Xeo
7:42 AM
wtf
why is the 2-param ctor explicit?!
 
Ah wait, C++11 also has a/b and min/max
 
@Xeo lol
 
Xeo
oh, because default arguments
ugh
horrible :<
 
How is that a reason for explicit?
 
Xeo
because it could be called with 1 argument
and you don't want implict conversion from any int-type
fuck default arguments :<
 
7:44 AM
param_type is also explicit
unspecified explicit sure :v
 
@Rapptz sounds like a recipe for disaster.
 
GCC probably just copied boost's version
 
Not much else to do really. Except maybe a std::pair or something.
Could param_type be defined as a private class?
according to C++11?
 
technically it can be anything lol
the standard doesn't mention anything about it or goes into detail about its semantics outside of listing the overloads that accept it
 
Time for Hell++ to bite you in the ass again.
 
7:50 AM
0
Q: Some way for allocating and initializing array faster than plain loop-and-set

user2799508This is how I allocate and initialize an array in C++. char *dataPtr; dataPtr= new char [40000]; int i; for(i=0;i<40000;i++) { dataPtr[i]=200; } Is there any other faster and cleaner way of achieving this as the for loop is taking considerable time for my application?

 
"You've been invited to join a chat: StackOverflow in Korean". Oh god.
 
Xeo
lol
 
morning
 
hello
 
I get one from the Chinese room everyday a while ago
but it has stopped now, thank dog god
7 hours ago, by chmod 711 telkitty
Waiting too ... If the council says there is still more missing for my nearly 100 pages application(including drawings & other reports) I will be very shitty ...
STILL SOMETHING IS NOT RIGHT ... DA submission - rejected again!
 
7:57 AM
I am disappoint that std::dynarray got voted out
 
@ParkYoung-Bae what is that?
 
Xeo
something awful
 
A C99-style stack-based dynamically sized array?
 
@rubenvb this (not necessarily stack based, no)
 
Xeo
potentially stack-based
 
7:59 AM
@ParkYoung-Bae Don't ever let Puppy hear that.
 

« first day (1355 days earlier)      last day (3592 days later) »