« first day (459 days earlier)      last day (4480 days later) » 

Xeo
6:00 AM
Needs more in-desu-rection!
 
@RMartinhoFernandes As a rule either my variadic packs are deduced (function templates), or it's a metafunction (class templates). Feels iffy otherwise.
 
Ok, just figured out what was meant
 
Xeo
 
so, the sizeof...(FArgs) should just be passed as a size_t template parameter to the helper class
that could work
 
Xeo
Damn name mangling. :(
 
6:03 AM
I think we need a syntax when explicitly supplying template parameters to say "and this is explicitly the end".
 
Xeo
Hm.
This is bad, with a second class... FArgs, int& reports 1 for operator()(int const&)...
So we somehow need to sfinae that sizeof...(Brgs) == sizeof...(FArgs)
 
Can you show the code?
 
Sadly, I have to leave this in your capable hands, cause my bed is calling.
Good luck all
 
Xeo
g'night
 
6:08 AM
and good night
 
Good night.
@Xeo Huh, where's the sizeof... test?
 
Xeo
Not there yet
I don't know where to put it. :|
 
Wait, that's not gonna work.
Or maybe it will...
@Xeo Of course.
Done.
 
Xeo
I know, but it's still bad
Oh, right, enable_if. There was that thing.
 
"Hmm, how do I turn a bool into SFINAE..."
 
Xeo
6:13 AM
@RMartinhoFernandes And what if Pling(const int &) should report 1?
@RMartinhoFernandes Sometimes, I'm stupid.
 
Oh, damn, the check needs to be stronger.
It needs to test if the packs are equal, not only in size, but in contents too.
 
Xeo
yay, recursion time..
 
> error: parse error in template argument list
This is like, the most unhelpful error possible.
 
Xeo
xD
 
What about "error: error"?
 
6:21 AM
Having to pack packs is annoying.
 
0
Q: C++ Circular Construction Issue

SlipflurryI am having trouble with an assignment. I have a class called Grid and Record. Record is Grid that stores how many times each position in a Grid has been accessed. Record has to be implemented in Grid so that Grid contains a data member of type Record that can store whenever a change is made to G...

"I have a terrible design, I wonder what to do."
 
Xeo
@RMartinhoFernandes Ah, faster than me. D:
 
You can make that an answer. I don't mind.
:)
R. Martinho Fernandes, Braga, Portugal
28.3k 11 53 107
Damn, still shows Java.
 
Xeo
@RMartinhoFernandes Wait, why doesn't that pose a problem if the packs are of different length?
 
6:24 AM
@Xeo The primary template is false.
 
Xeo
Ah
Xeo, In your code
25.9k 2 46 94
 
@CatPlusPlus Damn, you're clean.
 
Xeo
FWIW
I want to have silver badge. :(
 
So, what can I get a tag badge on to push this crap out...
 
Xeo
@RMartinhoFernandes Delete your answers.
 
6:26 AM
Ah, got it. Need to answer 7 pointers questions. I already have the score.
@Xeo But they're good ones!
TBH, I can't remember any of them.
 
How come I have more rep than you two?
 
You whore the silly questions.
 
They are catching up.
 
Am not.
 
Ah, I got a bounty for a Java question once.
 
6:30 AM
Wikipedia is down :)
 
Ah, most of my answers are on those questions that have two language tags for some reason.
Hovercrafts used to be made of tainted bread & were 1st employed in the 1350s as yak-herding devices in the Everglades. #fact #wikiblackout
"Jimmy Wales ate my homework."
 
Non-english Wikipedia still works. Knowing a second language is a good thing today.
 
Portuguese Wikipedia sucks balls.
Starting with the fact that it's not written in Portuguese.
 
user406009
Or you could just click the little x to stop the loading in your browser.
 
user406009
Or use noscript.
 
user406009
6:34 AM
Or turn off javascript.
 
user406009
Or use an adblocker.
 
user406009
Or use the foreign language version which has worse articles. :(
 
Screw Wikipedia and go to TVTropes.
 
Today it is justified.
 
Xeo
Damn, pack expansion is still not powerful enough
#include <type_traits>

template<bool B>
struct bool_c : std::integral_constant<bool, B>{};

template<class Test, class... Tail>
struct bool_ : bool_c<Test::value && Tail::value...>{};

#include <iostream>

int main(){
  bool_<std::is_same<int, int>,
        std::is_same<char, char>,
        std::is_same<float, double>> b;
  std::cout << b.value << '\n';
}
I want this to work. :(
so that && Tail::value is the pattern
 
6:39 AM
I have a conjunction constexpr function for that.
 
Xeo
?
 
    constexpr bool conjunction() { return true; }
    template <typename Head, typename... Tail>
    constexpr bool conjunction(Head h, Tail... t) { return h && conjunction(t...); }
 
Xeo
ah
 
You may want to call it all or something.
 
Xeo
and_v - and variadic :)
 
6:43 AM
Mine is variadic.
 
Xeo
"and variadic" is the name
 
Oh, you mean it's called "and variadic".
Damn.
In logic and mathematics, a two-place logical operator and, also known as logical conjunction, results in true if both of its operands are true, otherwise the value of false. The analogue of conjunction for a (possibly infinite) family of statements is universal quantification, which is part of predicate logic. Notation And is usually expressed with the prefix operator K, or an infix operator. In mathematics and logic, the infix operator is usually ∧; in electronics ; and in programming languages, & or and. Some programming languages have a related control structure, the short-ci...
Just testing chat.
 
Xeo
Still, && Pack::value is no pattern. :(
 
?
I think your bool_ is very badly named.
What if I want to combine the bools with or?
 
@RMartinhoFernandes This works?? Wikipedia is supposed to be down.
 
6:48 AM
@StackedCrooked The blackout on Wikipedia is JavaScript based.
 
I suppose the oneboxer doesn't run a JavaScript engine.
Since I never enabled JavaScript for wikipedia, it's been all fine and dandy for me.
hehe
Next version of C# will include a breaking change improvement: stackoverflow.com/a/8899347/46642
SHOUTOUT TO ALL THE PPL WHO FINNA FAIL THEY PAPER DUE 2MRW CUZ WIKIPEDIA DOWN AND YOU GOTTA CALL JESSE JACKSON BITCH ASS TO GET IT BACK ON
This is awesome.
 
user406009
 
3
Q: Books about learning programming with C++ as a first language

11D Reality Hacker Possible Duplicate: Recommended books on C++ Is there a canonical book on learning programming with C++ as a first language? I have toyed with Java and Python but when my laptop broke I couldn't program anymore. That was months ago and between now and then I have decided my real first...

lol, this got closed as a duplicate of a question which itself got closed as a duplicate :)
@RMartinhoFernandes Does "finna" mean "gonna"?
 
7:00 AM
@FredOverflow I'm finna assume that yes, that's what it means.
 
Why would Jesse Jackson invest any energy into putting Wikipedia back online? :)
 
I have no idea.
 
> Token: Jesse Jackson is not the emperor of black people!
> Stan: He told my dad he was...
 
Hello friends
Any one can help me?
 
Well, we can't really know that before we know your problem.
Have you posted a question on the site?
 
Xeo
7:12 AM
room topic changed to Lounge<C++>: No questions about asking questions. Violators will be shot. Survivors will be shot again. [c++] [c++11] [c++-faq]
 
I m a iOS developer
and now I want to start embedded programing
So need some help
how to start embedded programing
 
First you need a programmable dishwasher.
 
Means?
 
Some kind of device.
Something like this for example:
 
can you explain in detail
 
7:19 AM
Dammit, can't post pictures from wikipedia :(
@Stacky You don't do embedded programming on general purpose computers.
 
Why do you want to start embedded programming if you don't even know what 'embedded' means?
 
@RMartinhoFernandes
I know embedded
 
You do it on microcontrollers or DSPs.
 
I like embedded programing
ok
 
Right.
 
7:21 AM
any best tutorial for that?
 
Any kind of tutorial would be heavily dependent on the device you're programming for.
 
Have fun with that one. I gotta go check if I failed my logic test or very failed it.
 
ok
friends
 
Xeo
Damn
Robot, we got a problem
 
7:25 AM
Shout.
 
Xeo
The code may report 0 for default arguments now, but we're back to square one on overloaded operators, it just reports 0 even if there is a viable overload, because there is no calling context that forces the correct overload to be selected, as such we get sfinae
 
Xeo
Same for templated operator()
We need to split off the default argument case from the other cases
And if the "normal" cases report 1, we check if there actually are default arguments
 
Overloaded operator() is the reason I don't bother inspecting arguments.
 
Well, the entire premise of the question is silly anyway.
 
Xeo
7:29 AM
true
 
But you know, it's masturbation.
 
Xeo
I'm also not gonna bother any further, it was fun until now
So I'll just close all those ideone tabs and be done with it
 
@RMartinhoFernandes I just get a mental block once I figure out "I should make my callable trait lenient, not strict".
 
Xeo
Or maybe I'll leave the non-default-argument version for @Ben
Oh, yeah, and robot, we got another problem
Inherited operator()
But I think I know how to fix that
 
Do scanners need anything replaced or can I use them as much as I want?
Like printers need cartridges.
 
Xeo
7:35 AM
Okay, my fix isn't working.. all cases report 0 now. :(
Oh, I know why
It works \o/
 
^ can anyone please save me a trip to superuser?
 
Xeo
Wow, I thought template parameter packs have to be the last thing in a template-parameter-list? @RMartinho? @Luc?
 
@Xeo If they can be deduced they don't have to.
 
Xeo
ah, k
 
Or if it's a partial specialization then they can get matched.
 
7:38 AM
@IntermediateHacker Not under normal functioning.
 
Xeo
Damn, now another test case broke... the templated operator() :|
 
Of course, if you break it...
> Kitten BBQ = bad
 
Xeo
Awesome
 
I think my senator would be puzzled if I wrote to him or her regarding SOPA.
 
That explains where my pet cat went.
 
Xeo
7:40 AM
Err, robot, help.
 
Xeo
Why doesn't this report 1 for Blip?
It used to do that when the class type wasn't deduced..
 
Can you &G::operator() if it's a templated one?
 
Xeo
Afaik, yes, it's like an overload and the correct version gets selected according to the calling context
If there is no context -> failure
 
wait, are you guys actually talking about C++ in here?
 
Xeo
7:43 AM
@IntermediateHacker We're talking about template wankery.
 
damn. I'm allergic to that.
 
Xeo
Hm, let's see...
Damn, that also doesn't work
Now Blip and Urgh report 1, but everything else 0...
If I add sfinae overloads without a deduced class-type
 
Blip and Urgh. Sounds like you're doing something important.
Try using Ouch
 
It's not useful.
 
Xeo
I think I hit a roadblock here. Either one thing works, or the other thing. But not both.
 
7:47 AM
Why did you add the , typename C> at the end?
Oh right, nvm.
 
I'm trying to translate "Mother-F*cker" into Arabic, but can't find a good substitute.
 
I just tried to link to wikipedia in an answer... fail...
 
Xeo
I think I got it working..
 
Damn you! I just missed a question.
 
so erm... yeah... SOPA black outs ¬_¬ anything happening on SO in protest?
 
7:51 AM
@Mysticial Works fine in chat.
 
I'll show you the stupidest answer I gave to a question If you promise not to downvote it. I've already got 4 downvotes.
 
@IntermediateHacker not sure if I can promise that... is it funny?
 
Yesterday I leaked 270 rep :(
 
-4
A: What is the verb to take out compromises?

IntermediateHacker I don't think there is a word for it. Just invent your own.

 
7:54 AM
@thecoshman There aren't any good questions tonight to answer?
@IntermediateHacker I don't think you deserved all those downvotes...
 
@Mysticial I agree. maybe people just don't like posters.
 
@IntermediateHacker Apparently, they don't have a sense of humor... unlike us who can talk about sex and religion in the C++ room with impunity.
2
 
Xeo
Okay, this is stupid. If I do a find-and-replace in Gedit, with std::endl -> '\n', I get newlines instead of \n...
 
:%s/std::endl/\\n/g
whistles
 
Xeo
7:58 AM
Well, double-escape worked
And you needed that too
 
@Xeo Only because I have magic turned on.
 
Xeo
Right...
 
(Really, "magic" is the name of the option)
Oh, dammit, backslash is the only character that is magic even if I chose "very nomagic".
 
Xeo
8:31 AM
@RMartinhoFernandes :)
 
Yay proper self-tests.
Now I don't have to check them myself :)
 
Xeo
And the tests only fail on GCC because of some strange bug
That only shows itself with variadic templates
Clang 3.1 reports all as "passed"
 
All green on GCC 4.7.
 
Xeo
nice
Can you test with lambdas? There should be no problem, but you never know..
 
Sure.
auto l0 = [](int const&){};
auto l1 = [](int&){};
std::cout << "lambda - 'int const&' parameter:\n";
          test<decltype(l0)>(0, 1);
std::cout << "lambda - 'int&' parameter:\n";
          test<decltype(l1)>(1, 0);
Both pass.
 
Xeo
8:36 AM
Would be strange if not
 
Hmm, I can't declare a class and specify a base :(
 
Xeo
?
 
I wanted to do static_cast<derived*>(this) (like CRTP but this is not a template), but I can't. What cast do you suggest?
 
Xeo
Oh, that
Your class setup sounds strange
 
I wonder what the internet will be like after SOPA and PIPA.
 
8:41 AM
It's a linked list sentinel.
The nodes with data are of the subclass.
 
Xeo
@RMartinhoFernandes reinterpret_cast should work, so long no multiple or virtual inheritence is present
You could also try dynamic_cast, but I think you need a fully defined type for that.
 
@Xeo That needs vtables, no?
 
ANNOUNCEMENT: Please don't talk about C++ in the C++ room. Use the Java room for these kind of things.
2
 
Xeo
@RMartinhoFernandes Yes
Also, why not just this?
struct base{ void foo(); };
struct derived : base{ void foo(){ std::cout << "derived::foo()\n"; } };
void base::foo(){ static_cast<derived*>(this)->foo(); }
 
This is for a blog post intended for students on my uni, so I really didn't want to use reinterpret_cast :( I guess I'll have to handwave it.
@Xeo Oh, of course, outside of class!
 
Xeo
8:44 AM
lol
 
How could I miss that?
 
Xeo
How could I miss enable_if earlier today?
 
in Casual chat, 1 min ago, by IntermediateHacker
damn. they're talking about C++ in the C++ room. :(
(-_-)
<)(>
_//_
 
Xeo
lol
 
8:49 AM
Cool, the memory leak question is on the newsletter. I guess I won't need to work to rep cap today :)
1
Q: Singleton Class in C++

CodingMasteroI have used singleton calss following the example: singleton class But i get the error as "Unresolved external symbols" this is the code i tried out: #include<iostream> using namespace std; class singleton { int value; static singleton *instance; protected: singleton() ...

;)
 
Of Java room, maybe.
 
Xeo
0
A: How do I determine if a type is callable with only const references?

XeoAfter hours of playing around and some serious discussions in the C++ chat room, we finally got a version that works for functors with possibly overloaded or inherited operator() and for function pointers. #include <utility> #include <type_traits> template <typename F, typename.....

> @BenVoigt: okay, you and Xeo are both nuts! Great demo! – Matthieu M. 1 hour ago
lol
 
@RMartinhoFernandes I recently found out using Valgrind that inline actually does make my code faster. Especially if, before inlining, the code was in a .cpp file.
 
Xeo
9:04 AM
@StackedCrooked Bad link-time optimization?
 
For some reason I haven't managed to make link-time optimization work on my GCC 4.6 on Mac.
LTO is also a fairly new feature.
 
"Go faster stripes" change the aerodynamics of cars, and how much light pressure is inflicted on them.
 
Xeo
So, I expected a flood of upvotes after posting the answer... and only got 1 :(
 
std::set<int>::iterator is bidirectional, right?
 
Xeo
yes
 
9:07 AM
@Xeo It's mine!
 
Xeo
I guessed that much. :)
IIRC all container iterators are atleast bidirectional, apart from forward_list
 
@Xeo How about those volatile and lvalue/rvalue qualified operator() overloads? :p
 
Xeo
@LucDanton Uguu....
 
Get cracking!
Qualifications should be templatable.
 
Xeo
Seriously, this is getting exponential
@RMartinhoFernandes This! SO MUCH THIS!
 
9:10 AM
template <typename R, typename C, typename... Args, qualification Q>
void f(R (C::*)(Args...) Q);
Lovely.
 
@Xeo +1
I haven't even read it yet :D
 
Xeo
lol
I mean, with C++11 we have a shitload of possible qualification combinations
 
2 * 2 * 3?
 
@RMartinhoFernandes Or really the implicit argument could be made explicit. template<typename R, typename C1, typename C2, typename... Args> void f(R (C1::*)(C2, Args...);
(For every ptm syntax.)
 
@LucDanton But that won't help with ref-qualifiers.
 
Xeo
9:12 AM
@RMartinhoFernandes it will
because the implicit parameter contains those
 
Good point actually.
 
Ah, ok.
@Xeo What about "none"?
 
No, unqualified member functions are problematic.
 
The implicit parameter is not passed by value.
 
Xeo
the implicit parameter is not passed at all
it's only for overload resolution
 
9:14 AM
@Xeo But it carries either & or &&.
There's a third ref-qualification:
 
Xeo
Anyways, template<class R, class C> void f(R C::*) will capture any member pointer, be it function or data
but I can't use that here. :|
 
Using pass-by-value as a convention for non-lvalue/rvalue qualified members is problematic, too.
 
Xeo
@RMartinhoFernandes "“lvalue reference to cv X” for functions declared without a ref-qualifier or with the & ref-qualifier"
 
So, no telling apart.
 
And unqualifed members can be called on rvalues, too. With such a constrained pointer you can't.
 
Xeo
9:17 AM
right, but if there is no ref-qualifier, the lvalue ref is allowed to bind to rvalues
 
(Or if you can, it looks inconsistent.)
 
Xeo
So we need a qualification template parameter type
:|
 
Nevar.
 
While we're at it, why not add string template parameters? ;)
 
Damn, why is it that I have to live in a damn town. :(
 
Xeo
9:18 AM
The interesting thing, when using R C::*, R is the function type IIRC.
 
@Xeo Correct.
 
Xeo
And it doesn't carry any qualifiers whatsoever
 
So you can 'centralize' the problem to one trait to extract return type and argument types. Expect lots of specializations (and in all likeliness, preprocessor magic).
@Xeo It does.
 
Xeo
does?
 
void(int) const is a valid function type.
 
Xeo
9:20 AM
oh
damn
 
Get cracking on that trait, so I can copy it.
I hit the rep cap, so I'm gonna go buy some food. See ya.
 
Xeo
template<class FPtr> struct get_sig;
template<class T> struct get_sig<T*>{ typedef T type; };
template<class T, class C> struct get_sig<T C::*>{ typedef T type; };
You only need to make sure that what you pass is actually a function pointer
 
At one point I had two specializations foo<Sig C::*, std::is_pointer_to_member_data<Sig>::value> and foo<Sig C::*, std::is_pointer_to_member_function<Sig>::value> or something.
 
Xeo
Hm, does remove_cv work on function types?
 
I remember asking myself the same question, but not the answer :(.
@RMartinhoFernandes For various reasons I had to solve my actual problem another way so I don't really have a need for such a trait.
 
Xeo
9:26 AM
remove_cv doesn't work. :|
 
My approach with pointers to members is to delegate the 'problem' to std::bind and the like and to treat everything as a functor. So I only get 'messy' with qualifications/ptm when I'm writing one of those 'the like' utility (in this case that was my make_overload).
@Xeo IIRC officially function types have no cv-qualifications, so making the type traits operate on the (implicit parameter) qualifications would be inconsistent with how others types are treated.
 
Xeo
:|
 
Writing traits such as add_const_qualification with the partial specializations it entails would definitely be a bore though.
 
Xeo
well, variadic templates make life easier
 
Variadic or not, make them lenient. Accept functors, don't inspect argument types :)
 
Xeo
9:32 AM
Oh, I meant for the "remove qualifiers" stuff :)
It's interesting just how well inheritence plays together with TMP
 
Woah... I just rep-capped...
A newbie just asked a pretty damn good floating-point question...
 
I just wondered: if we use cv as a placeholder for cv-qualifiers (e.g. void foo() cv ;), what could we use for lvalue/rvalue qualifiers? I figured that lvalue/rvalue is really about value category, but that ends up as vc. D'oh!
 
@Xeo Missing vc-quals :p.
 
Xeo
GCC 4.5.1 doesn't have them
I'm copying it to my debian box for testing with clang right now. :P
> warning: template argument of 'const' qualified function type is a
> GNU extension [-Wgnu]
Well, fuck.
 
9:36 AM
Oh yeah, they're ref-qualifiers in the grammar.
void foo() cv ref ; it is then I guess.
 
Xeo
great
MSVC doesn't capture void (X::*)() const with T C::* partial spec
Graaah, I just want to have a fully standard conforming compiler. T^T
 
Missing parens.
 
Xeo
@RMartinhoFernandes No, they're explicitly missing
 
void (X::*)() <- missing parens there.
 
Xeo
Oh, those
I have them in the code :P
Seriously, MSVC is not TMP friendly.
 
9:47 AM
1,2,3; I'm back in the room
 
Xeo
> Function pointers do not have an operator() so they ahould report that they are not callable according to the question. Otherwise if you want to catch any callable type, you need to handle also class types that have a conversion function to function pointer or reference type. – Johannes Schaub - litb 23 mins ago
More problems. :(
 
oh god, so much white space :'(
 
@Xeo No, not really. Those are the limitations set forth by the OP.
 
Xeo
@LucDanton The first part, yes. However, the second part is true.
Apart from the fact that the first part is easy to "fix"
Anyways, I'm not gonna bother with this any further today
 
I've always referred to the second part. Especially since it's not easy (i.e., sensible to do really).
 
Xeo
9:59 AM
I already spent way more time on it than originally planned
 
@Xeo See, I skipped straight to that part.
 

« first day (459 days earlier)      last day (4480 days later) »