« first day (489 days earlier)      last day (4452 days later) » 

12:00 AM
@sehe derp XD
 
@hoxieboy Oops, I solemnly promised not to do it again ... :(
git checkout -f HEAD@{yesterday} && sloccount .
Totals grouped by language (dominant language first):
cs:           27023 (95.51%)
xml:           1270 (4.49%)
 
@sehe hmm, you already said that once... almost...
 
dangit sehe, what did I say!
XD
 
Only 124 lines of code in a day.
@MooingDuck See ^^
 
@sehe figured it out
 
12:08 AM
:D
 
my current project
../../bin/cloc ../../src/ ../../inc/ ../../tst/
584 text files.
584 unique files.
5 files ignored.

http://cloc.sourceforge.net v 1.53 T=0.5 s (1158.0 files/s, 131116.0 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C++ 325 5476 9397 28396
 
Ok, I hope it is not my UserScript that destabilizes the entire chatroom
 
@sehe someone might be trying to hax so chat :o
 
@sehe is that what's going on?
 
@MooingDuck erm... ^^ "i hope it is not"
 
12:11 AM
what the, I removed two thirds of my tests, and now my remaining test is about 1000 times slower than it was. I'm beginning to think MSVC's profiler isn't worth much
 
Holy $4!7 (sorry) but the author stated million line long programs are not uncommon ._.
 
@MooingDuck Instead, you should start to appreciate that benchmarking is hard.
 
....or I'm running with the wrong flags set. (nevermind....)
 
I honestly hope it was teams that made such programs... O.o
 
@Hoxieboy yes
@Hoxieboy my codebase at work is closing in on 4000 cpp files
 
12:13 AM
Next stop:
318
A: What can I use to profile C++ code in Linux?

Mike DunlaveyOK, downvote time... If your goal is to use a profiler, use one of the suggested ones. However, if you're in a hurry and you can manually interrupt your program under the debugger while it's being subjectively slow, there's a simple way to find performance problems. Just halt it several times,...

 
@MooingDuck XD I guess if you know the language good enough you can speak it fluently
 
@Hoxieboy I'm currently counting header files. Parts are also written in Java and C#
9102 header files
 
@MooingDuck reminds me of my two headed, 3 legged mutant spawn with no eyes I created using java and python a while back :)
 
why so many more headers than cpp? No idea!
 
@MooingDuck hahaha - template madness?
 
12:15 AM
@Hoxieboy The entire project for our team was (recently):
Totals grouped by language (dominant language first):
cs:          249585 (93.02%)
xml:          18239 (6.80%)
sh:             476 (0.18%)
java:            10 (0.00%)
 
@kfmfe04 no, it's mostly C with classes, virtually no templates. Codebase is mostly older than I am
 
@sehe lol i love the little smattering of java in there X3
 
@sehe protip: don't mix java with other languages
 
@MooingDuck Don't mix java with computers
 
@MooingDuck protip(even though I'm not a pro :o): use java only for internet stuffs, its got a foothold there!
 
12:17 AM
@Hoxieboy I really want to argue with that, just because I dislike java :( But you're right.
 
@Hoxieboy Oh and I know precisely what it is. I used Mono Cecil to generate java code from our released assemblies. The java in turn would run in Eclipse as a [RSM ](www-01.ibm.com/software/awdtools/modeler/swmodeler/… to generate UML documentation artefacts for the released code :)
 
lol what are you guys working on again?
@sehe ^
 
So the smithen of Java is the code template used by the code generator :)
 
what the... my thin wrapper around std::lower_bound takes more time than std::lower_bound....
 
@sehe - just out of curiosity, do you find that you can get more done with fewer lines of code in cs vs cpp (I'm guessing .Net helps, at least)?
 
Xeo
12:19 AM
@JohannesSchaublitb Confirm what?
 
4
A: Can constexpr function evaluation do tail recursion optimization

Richard SmithBy the rules in [implimits], an implementation is permitted to put a recursion depth limit on constexpr calculations. The two compilers which have complete constexpr implementations (gcc and clang) both apply such a limit, using the default of 512 recursive calls as suggested by the standard. For...

I think
 
@Hoxieboy I'm (co)building software that distributes money to educational institutes in the Netherlands. That is a semi-government body, and we transfer EUR 24 Mio each year (was it 34?)
 
@Hoxieboy I try to make answering machines speak Arabic
 
@kfmfe04 Oh absolutely. I think C# rocks. I love C++ though, that's just a matter of preference/affinity/sick twistedness :)
 
@sehe cool :D
@MooingDuck Rofl.
 
12:21 AM
@Hoxieboy I wish I were joking :/
 
@Xeo Fate Zero is fucking good!
 
@MooingDuck I know a guy in that field. Jacek Jarmulak, ever heard of?
 
@sehe nope
I dunno anyone in my field
 
IMO it's the best Type-Moon release I've seen until now. (I'm at ep9 now.)
 
@MooingDuck Oh god you aren't? ._. do you know arabic? XS
 
12:22 AM
my company makes telephone and misc communications things
 
@Hoxieboy nope, though I know a few words of Spanish
 
@sehe that's what I thought - I only dabbled in C# like 5-6 years ago - liked it best out of the .Net languages back then...
 
@MooingDuck http://www.resolvity.com/ : Intelligent, Personalized, Finely-Tuned
IVR Applications ... blabla .. Speech recognition
 
@MooingDuck idk how you do your job then ;) I know german and a few words of russian, i plan to learn french and spanish though :D
 
12:24 AM
@Hoxieboy I rewrite bad code to use multilingual tools, and then help the translators and voice "talents" to do the recordings. I actually have to do lots of languages, but Arabic is most interesting
it looks neat
 
@sehe speaking of speech recognition, my friend re-created skynet using python and an old computer XD
 
@sehe: Either the compiler cheating on the tests or I don't know how to interpret the results. Either way, it's smarter than I am :/
 
Did we ever figure out how to get GDI+ to stop drawing characters unevenly spaced?
 
@MooingDuck Where does that bad code come from? lol
 
@Hoxieboy MY COWORKERS WHO DON"T KNOW ANYTHING ABOUT MULTILINGUAL CODE
 
12:27 AM
XD
 
@Hoxieboy (there might be some anger there)
 
@MooingDuck yeah I kinda took the use of ALL CAPS RAGING as a sign of anger :3
 
Found it, compiler elided tests again
I'm not good at this
 
@MooingDuck still getting the hang of the chat Userscript; It turns out I accidentally starrted chat.stackoverflow.com/transcript/10?m=2663308#2663308
 
@sehe YOU BROKE SO! :D
 
12:29 AM
@MooingDuck volatiles help a lot :) And just summing/xoring intermediates into meaningless results helps too, as long as you print the resulting nonsense value at the end. The compiler will feeel obliged to faithfully calculate your nonsense
 
what exactly is the chat Userscript? The code a user (well, dur) uses to connect to the chat server?
 
@MooingDuck YOU SO BROKE! (FTFY)
 
@sehe volatile is a good idea
 
@Hoxieboy I linked to it before
@MooingDuck Mentioned that too
 
@sehe probably
 
12:30 AM
@sehe -.-
 
@MooingDuck for some reason can't find it. It was basically my first response to your whole benchmarking thread on this chat :) It seems to have gone missing.
 
@AlfPSteinbach It's similar in Dutch.
 
Found it:
57 mins ago, by sehe
@MooingDuck Wrap the inner loop in a loop with large number iterations; Make sure the results get used (or the optimizer might optimize the whole loop away). One way it to increment a 'global' counter, declared as volatile size_t counter = 0;
 
THUS BOOK CONTAINS TOOO MUCH INFORMATIONS... head spontaneously combusts whilst eyes melt
 
@StackedCrooked And mainly due to the fact that Madchen is a dimunitive. All dimunitives are neutral
 
12:33 AM
My code is not eleven times slower than map -_- stupid profiler.
 
@Hoxieboy I never had that experience with Stroustrup. I did have it with Alexandrescu and some others
 
@sehe X3 Well, when exactly did you start to read the book in relation to learning the C++ language?
 
my map test is still 5% test, 95% showing results after the test. I'm pretty sure I fail at this
 
@Hoxieboy It was the first book I read. It was recommended to me, but I got the second edition, I think (anyways, that's what's on my shelf today)
 
Xeo
@StackedCrooked :D
 
12:36 AM
@MooingDuck You are simply not iterating often enough/ If your benchmark runs less than, say, a minute, you will get quite a bit of skew/noise
 
@sehe :) I have the 3rd edition, but did you know any C++ before hand?
 
@sehe that seems to be it, as I change things, I keep having to (vastly) change the number of loops (which is why for a long time I just looped for 5s....)
 
Does anyone know how to get GDI+ to not do this
See how it bunches letters together
I'm already using StringFormat::GenericTypographic and stuff
 
Xeo
Just reminded me of this
 
@Hoxieboy afraid not. I did have some Pascal, VB, assembly experience. But I guess I took up C++ from then, without ever bothering about C. I must admit I never applied it until I wiggled my way into a second C++ job which had a nice team. I taught myself on the job and worked many many hours overtime
 
12:38 AM
lol
 
@SethCarnegie Are you sure it is not limits of monitor DPI + aliasing settings?
 
no wait, profiler is accurate. Why is my code suddenly so much slower?
 
@MooingDuck It is being run?
 
@sehe I am using ClearTypeGridFit because any other setting looks like crap
 
@sehe I guess thats one way to learn isnt it?
 
12:40 AM
@SethCarnegie GridFit seems to point at the solution, though
 
@sehe there is no "plain" ClearType
and yet MSVC++ for example has no problem displaying monospace fonts actually being monospaced
 
@Hoxieboy Yup. Better do it while you're young, because later you won't have the attention/energy or your wife/kids won't let you :)
 
XD
 
@sehe I'm beginning to think my code is just slow, and it wasn't being run before when I thought it was fast
 
@Hoxieboy Oh, and don't forget to stop it when you have achieved the goal. Don't risk burnout for no reason (I think I may have been trying to make up for my lack of college degree, and I have seen burnout)
 
12:42 AM
I will give someone 50 rep who can solve this problem
 
@MooingDuck I recognize the feeling. If you want to sympathize, let me link you to a splendid answer of mine that basically boils down to the same.
@SethCarnegie Nice. Bounties are made for that
 
@sehe that's what I mean
 
@Sehe: hmm, now that I'm printing volatile results to be sure the tests ran... why doesn't my code have the right answers...?
@Sehe: I'm sure this is all your fault somehow
 
@sehe I guess I should take to heart what you're saying, I'm trying to make every class I take in highschool right now relate to programming, perhaps that should help no matter what language (ew, java) I'm actually thinking of boycotting java in the class to make the class use C++ :3
 
@Hoxieboy if you do that you'll probably fail
 
12:46 AM
@SethCarnegie Not if I ask if the class would use C++ instead of java, by boycott I meant suggest :3
Gtg eat
 
@SethCarnegie by definition. Also, what use is there in boycotting your curriculum? You can do a better job at that, with the added benefit of not paying the school fees :)
 
oh, my tests weren't identical. Oops. different RNG seeds
hmm, does srand affect std::random_shuffle?
 
@MooingDuck there, found it. I'm not overly proud of what happened there: stackoverflow.com/questions/8133403/optimize-this-function-in-c/…
 
@MooingDuck implementation defined if anyone cares
 
I mean, the thinking was alright, and amazingly, the 'optimized' version was almost as fast as the original, while doing all kind of funky extra stuff like prescanning the input data (that was surprising). But it took me a whole day to realize there was an error in the testbed that led to subsequent benchmarks to 'appear' to produce correct results, when they didn't. Fixing that made the performance benefit vaporize, of course :)
@MooingDuck Ah, at least I got that part correct in my optimization debacle :)
@MooingDuck I had made the good effort of verifying correctness of output by comparing the hash of the data.
Haha, found another optimization answer of mine, that surprisingly never gathered even a single vote
0
A: C++ Search Performance

seheA number of slight improvements. Benchmark before: 7 minutes 56 second and counting (will update) Update: finally finished in 15m25s, yielding a performance increase of roughly 3000 x Benchmark after: 0.3? seconds (see below for updated figures) Code: #include <set> #include <string&...

 
12:55 AM
@sehe I had a homework assignment like that once
 
@MooingDuck Yeah it is pretty classic (data structures and algorithm 101)
 
we were given a file with one billion 32-bit integers, and we had to sort them on a cluster using openmpi. My first draft took 8.6 hours. I added code to make it wait until previous steps were done before continuing and it dropped to 10 minutes.
blew my teammates minds that I got that speedup by making it go slower :D
 
@MooingDuck Yeah. Those kinds of experiences > any textbook
 
first draft was reading, sending, recieving, and saving 4GB of data (each) more or less simultaneously on the primary machine, with 1GB of RAM.
 
Ok, on that note, I'm off to bed. Power cord yank :)
 
1:00 AM
hmmm, random_shuffle doesn't appear to be shuffling
 
0
Q: GDI+ draws letters bunched together

Seth CarnegieI feel like I've read a question similar to this but I can't find it, so please close if duplicate. I am trying to draw text with Graphics::DrawString with a monospace font (Consolas). However, when I draw the text, the letters are not evenly spaced. Here's what it looks like: As you can see,...

 
like all my other problems, that one was imaginary too
@SethCarnegie it'd be interesting if you altered the picture to say the number of pixels between each i.
 
What do you mean
@sehe thanks for the edit
 
That was my first mobile plonk. I should mute it now to avoid waking my wife (2 a.m.)
 
Hello everyone. I've been busy with other assignment and I really missed this chat room. But now I'm back. Almost done with my checkers game.
 
1:12 AM
Why does everyone think you're using .NET if you mention GDI+?
 
Can someone tell me what project1.c:25:16: error: expected expression before '=' token is tell me?
 
Not without seeing the line
 
@SethCarnegie I don't know, wasn't GDI years earlier?
 
when the error say project1.c:25:16 25 is the line right? or is it line 16?
 
@LearningC line 25, character 16.
(character 16 is probably the =, we need the whole line)
 
1:15 AM
Oh that explains it. I had !==
 
gah, std::vector(count) doesn't use the default constructor for all of them? Darnit.
 
@MooingDuck what does it use?
What else could it use?
 
@SethCarnegie default constructs one temporary, copy constructs the rest. At least in C++03
 
Ah
That seems kinda dumb
 
@SethCarnegie My test code default constructs with a random value, so they're all uniquish :/
That means all of my tests are completely invalid
 
1:20 AM
@MooingDuck Fixed for C++11. There was the same issue regarding resize btw.
 
@LucDanton I don't have a C++11 profiler, just C++03 :(
 
@MooingDuck make the copy constructor use a random value :) oh wait...
 
@SethCarnegie I need valid copies
ah well, I can just do it myself, just adds a few lines
 
std::generate_n
 
@Luc STL wins again
 
1:24 AM
Well, writing the functor is somewhat inconveniencing, what with C++03 and all.
Never understood why constructors are 'sacred'. And I think that's not specific to C++ but something of a cornerstone of inheritance-style OOP.
 
@LucDanton it's not that bad: template<class load> load genfunc() {return load;}
@LucDanton "scared"?
 
@MooingDuck Point is, it's out of line.
 
@LucDanton yeah, I'll deal
 
@LucDanton yeah, I don't understand why you can't pass the address of a ctor, etc
 
@MooingDuck Sacred, holy, consecrated, divine.
 
1:26 AM
@SethCarnegie makes sense. Also, why it doesn't return a reference to itself, like assignment operators
 
Because I guess it could return something else and screw things up
 
@SethCarnegie it simplifies the rules, and there's already a million ways to shoot yourself in the foot.
@SethCarnegie besides, then it allows some cool things, namely, it's now a function.
 
It would screw more things up than it would fix
for instance
Type t;
You have no idea what type t is because the constructor could return something other than a Type
&
 
@SethCarnegie no, it would still construct a Type in ts memory, the function just returns an ignored value.
it would only kick in for things like`Type(thing).to_string();`
 
That seems pretty pointless
just add the capability to treat the constructor like a function and it would do what you want without being screwy
 
1:30 AM
@SethCarnegie simplify the rules, and allow for some bizzare magic if you're careful
 
What would be something magical and enchanting that you could do if you could specify the return type of a constructor
 
Hi again
 
template<class iterator, bool thingy> struct apple {
int apple(iterator i) {return 42;}
};
template<class iterator> struct apple<iterator,false> {
int apple(iterator i) {return 0;}
};
int main() {
return apple<char*, true>("mystring"); //partial function specialization
}
 
anyone here good at find out why I can use xming on putty?
 
before I sleep, quick question: I have a random variable from 0 to 1023, and I want to reverse-map it so that 1023 -> 0 and 0 -> 255 and 512->127
 
1:36 AM
@KianMayne 255-n/4 I think
:2663767 n is your variable
 
What is that a reverse of.
 
Yeah I got that, I'm sleepy
 
@KianMayne doublecheck my math, I'm too lazy
 
@MooingDuck I don't see why that is helpful
 
@SethCarnegie partial template specialization? It's just a tool like any other
 
1:37 AM
No, I mean returning a value from a constructor
 
@LucDanton It's part of an Arduino thing that takes analogue input from an LDR and then makes an LED brighter the darker it is
 
Ha! I repcapped before Jon Skeet today... I feel like I've accomplished something.
 
No I mean, you say you want to reverse-map it. What's the original map then.
 
@KianMayne I checked, it matches those numbers for integers
 
lol
 
1:38 AM
@MooingDuck Ahh cool :)
 
@LucDanton he wants a normal mapping, ignore the vocab
@KianMayne it rounds a little funny, but that's alright I think
 
@LucDanton Well in arduino the map function is like this map(int x, int fromlowerBound, int fromUpperBound, intToLowerBound, int toUpperBound) I'm just making up words
 
why did I get +5 for an upvote today?
 
@MooingDuck Question upvote?
 
@Mysticial oh, that explains why it's blue
why does my code go slower and slower the more I fix it? :(
 
1:41 AM
@MooingDuck lol? What exactly are you doing to it?
 
@Mysticial turned out most of my timing tests were getting optimized out :(
 
Yeah, that'll happen. Micro-benchmarks can be tricky to write since you have to outsmart the compiler.
 
Thanks @MooingDuck! It's working well now (:
 
. ideone.com/plEoJ ? :)
 
@Mysticial In full tests, I made a function that mimics std::map::find for a sorted vector, but it is significantly slower than the map, even for small counts of small types.
ilist again? I'mma go hurt myself
 
1:52 AM
@MooingDuck Isn't this the same issue you had a few weeks back? Or is it a different data structure this time?
 
@Mysticial I've been working on this code for months
 
@MooingDuck Don't get stuck on one performance thing for too long. Though I can admit it can be pretty addicting at times to try and figure out why X is faster than Y and why Z just sucks...
 
it should be trivial!
@Mysticial this is entirely for my own amusement, I'll feel free to obsess wherever I want :D
 
@MooingDuck Fair. :)
 
I'm now within 15% of map's speed
I'm actually proud of the class, it seems well done. The test suite... not so much
template magic everywhere, no comments....
 
1:56 AM
Geez... SO as had 3 questions and 4 answers go 100+ in the past 7 days...
 
@Mysticial stop showing us up :P
 
No, I'm just browsing through the 10k tools. They list all these things.
anyways, gonna take my nap. I got a long night ahead... probably not gonna sleep until 5 or 6 am.
 
@Mysticial I'm out too. Later
 
morning
 
2:41 AM
hi can i ask a question?
ok yes i can ask a question. just ask it, me. don't ask about asking it, me.
well, the following does not compile, neither with MSVC 10.0 nor g++ 4.6.1:
#include <functional>
#include <utility>

struct S
{
    void foo() {}
};

int main()
{
    using namespace std;
    typedef decltype( &S::foo ) MemFuncPtr;
    typedef remove_pointer< MemFuncPtr >::type MemFunc;
    typedef function< MemFunc > Func;
    typedef Func::result_type Result;
}
?
 
of course not
there's no such thing as remove_pointer< MemFuncPtr >::type
member function pointers are not pointers of any kind
 
oh, that works fine
it's the last line that's problematic
or am i too tired here?
 
more likely, your compiler is simply giving you a bad error message
 
well both are.
 
well, your code is wrong
so try solving that first
 
2:46 AM
since your comment I tried function< MemFuncPtr > but same story
 
of course it is
 
std::function does not have specializations for anything except Ret(Arg...)
and Ret(T::*)(Arg...) is most certainly not on that list
and neither is ... whatever the result of remove_pointer is either
 
so i must bind the thing first, if possible
 
or use a lambda, depending on what you need
 
2:48 AM
well i just want the return type of &T::m, regardless of arguments of m
 
that doesn't exist
overloading?
template?
 
where m can be any non-static member function
 
anyway, the best you could do is write your own template which does the job, I sincerely doubt that any such thing exists in the Standard library
member function pointers don't play well with generic libraries at all
 
THere is result of but then you need to know the signature already, so it's useless
Coffee, I think
thanks
 
2
A: What's wrong with this dereferencing statement?

Seth Carnegiestr points to a string literal which resides in memory where it is undefined behaviour to write to. Many times the compiler will put these string literals into memory with permissions that do not include write-permissions. This is why you're crashing. Change it to this: char str[] = "Hello"; ...

another question that could be answered by the SOFAQ
 
2:53 AM
so what's new?
 
Well with strict C++11-support it will disappear. :-)
 
Anyone here use tkdiff?
Do C has a something for backscape? Like return = \n.
 
@LearningC assuming you mean "backspace", have you tried \b
 
@AlfPSteinbach Thank you. Going to try.
@AlfPSteinbach I used \b but it came out "\b"
 
3:07 AM
Yes, the common cold is back
 
@DeadMG: I solved using brute force, faster than figuring out a general solution:
    template< class MemberFunc, MemberFunc pMemberFunc >
    class CallMember
    {
    public:
        //typedef typename cpp::ResultOfMemberFunc< MemberFunc >::T      Result;

        // This factory is only used to prevent mis-interpretation of expression as a cast.
        static CallMember instance() { return CallMember(); }

        auto operator()( Widget* const pObject ) const
            -> decltype( (pObject->*pMemberFunc)() )
        {
            return (pObject->*pMemberFunc)();
        }
I seem to remember that auto should figure out the return type from simple return expression, but Visual C++ 10 insists on having it explicitly specified
 
only for lmbdas
 
oh
"the inconsistent language" :-/
 
C++, buddy
by the way
why bother taking the member function by template when you can only support T() as a signature?
 
Huh?
The code above supports four signatures
 
3:17 AM
which are?
 
(), (A1), (A1, A2), and (A1, A2, A3)
 
ohhh, the "see full text" thing
didn't notice
 
That's why I say it's brute force solution
 
no variadic templates
 
It would be better with out-commented typedef at the top
No variadic templates in vc10
:-(
It's just a way to make the Windows API message cracker macros call member functions.
Like
        virtual raw::LResult wmHandler(
            raw::UInt const     messageId,
            raw::WParam const   wParam,
            raw::LParam const   lParam
            )
        {
            typedef Widget W;

            switch( messageId )
            {
            case WM_DESTROY:
                return FORWARD_WM_TO( this, W::onWmDestroy, WM_DESTROY, wParam, lParam );
            }
            return ::DefWindowProc( handle_, messageId, wParam, lParam );
        }
where the FORWARD_WM_TO macro is defined as
    #define WINAPI_CALL_MEMBER_( m )    CallMember< decltype( &m ), &m >::instance()
    #define FORWARD_WM_TO( pWidget, memFunc, symbolicMessageId, wParam, lParam ) \
        HANDLE_##symbolicMessageId( pWidget, wParam, lParam, WINAPI_CALL_MEMBER_( memFunc ) )
 
3:22 AM
Do you have std::mem_fn? If I can read the specs correctly it has a result_type member.
 
Oh, let me take a look. Sounds great!
 
I think the best description of it is that it's std::mem_fun done 'the right way'.
Has quite a bit of overlap with std::bind nowadays but it's still neat.
 
Well, I see only support for no argument and 1 argument.
Checking bind...
 
> fn shall have a nested type result_type that is a synonym for the return type of pm when pm is a pointer to member function.
Implementation not up to spec :(
 
3:41 AM
I looked the wrong place but after looking the right place I still could not get that to work.
So, brute force.
 
Xeo
3:59 AM
@LucDanton std::ref has, IIRC, according to spec also a nested result_type if the object is callable
 
@Xeo A pointer to member is not callable.
 
Xeo
> reference_wrapper<T> has a weak result type (20.8.2). If T is a function type, result_type shall be a synonym for the return type of T.
If a call wrapper (20.8.1) has a weak result type the type of its member type result_type is based on the type T of the wrapper’s target object (20.8.1):
— if T is a pointer to function type, result_type shall be a synonym for the return type of T;
— if T is a pointer to member function, result_type shall be a synonym for the return type of T;
— if T is a class type with a member type result_type, then result_type shall be a synonym for T::result_type;
— otherwise result_type shall not be defined.
So you actually do get the result_type for member function pointers
 
@Xeo: thanks, I'll try later, I'm too tired now.
 
Xeo
Hm. It seems like you can use std::ref just the same as std::mem_fn.. strange stuff
 
Well, you'd need an lvalue, wouldn't you?
Can't do std::ref(&T::foo).
This self-assignment question is making me dangerously aware of my own operator= implementations.
Good news is, only one bugged operator=.
Guess I can pat myself on the back for not writing operator= much these days.
I should rewrite that class with a std::unique_ptr and be done with this silliness.
 
Xeo
4:22 AM
Heh, std::unique_ptr is required to be self-assignment checked, right?
 
Yeah, it's clever. Assignment is equivalent to reset(other.release())
 
Xeo
heh, neat.
 
So release() puts *this in the *this == nullptr state, so that when reset'ing, nothing bad happens.
 
Xeo
I have to admit, that is actually very neat.
You know, I think I'm gonna rewrite my answer with that implementation. It's simple, concise, and works. Any idea where it might make problems?
 
If you need copy semantics.
It works in my case because my type is move-only.
But yeah, normally I don't write special members because I pick the right type for my data members: std::unique_ptr and the Standard containers make recurring appearances here...
 
Xeo
4:29 AM
Well, d'uh, obviously that reset(other.release()) would only be used for move assignment, where the copy assignment is done as normal with copy-swap in client code or Howard's version in lib code
 
Oh that.
I think that's silly.
 
Xeo
@LucDanton Actually, that was what my answer first was going to be. Pick the right members - never have a problem. But then I couldn't remember if library types are required to do the self-check
 
Explaining such-and-such functionality in terms of some other functionality, and so on and so on.
At some point the buck has to stop and you have to find your primitives. For me operator=, being a special member, is one such primitives.
So I don't explain operator= in terms of other idioms or whatever, I just make it work.
@Xeo Hence why my answer is obviously superior, I'm quoting the Standard.
Also one of the reason why I don't like copy-and-swap.
"Assignment is easy! Make it work in terms of construction and swap."
Or I could make assignment work and have swap in terms of move, for free. It's all the same work in the end.
 
Xeo
Hm.. I'm wondering if I should just delete my answer.
 
I also contemplated that, but given that std::unique_ptr is in fact self-assign safe I'm keeping it. Always nice to have the Standard stuff as an example.
 
Xeo
4:35 AM
Oh well, I'll just trash it.
And I'm off to sleep, g'night.
 
HOLD ON HERE
sweet
 
4:53 AM
#TellVicEverything must be the funniest Twitter trend ever made.
 
now all I have to type is date+date (without the +) and it inserts the date and time for me :D
._.
eh
2/16/2012 9:59 PM
derp
 
idk I'm working on a parser that looks at incoming text
2/16/2012 10:00 PM
Idk how lazy a person can get (a person like me :D) but I think I'm going to make it capitalize my sentences for me XD it already helps with words like I'm and I
I used idk to much
maybe make it take out "idk" from incoming sentences :3
 
5:30 AM
good morning.
the weather has been so weird lately. believe it or not, there's a storm-cyclone-wind-cloud kinda thing going on outside....... and it's supposed to be a desert. I hate climate change.
 
lol
 
5:51 AM
is the Robot still MIA?
 
Anyone got thoughts about this?
0
Q: gcc error with Python C API code - "ISO C++ forbids casting between pointer-to-function and pointer-to-object"

Faheem MithaThe following fragment does nothing, but illustrates the problem. This was tested with the backport of a gcc 4.7 snapshot from Debian unstable to squeeze. #include <boost/python/object.hpp> #include <numpy/arrayobject.h> int main(void) { PyObject* obj=0; npy_int64 val; PyArray...

Just posted.
 
6:17 AM
Please tell me 5.2.9p2 prohibits the static_cast in this question:
0
Q: Partial specialization syntax confusion

NulledPointer To define a specialization that is used for every Vector of pointers and only for Vectors of pointers, we need a partial specialization: template <class T> class Vector <T *> : private Vector<void *> { public: typedef Vector<void*> Base; Vector(): Base() ...

 
^ This song seems to be getting popular around here.
 
6:42 AM
@BenVoigt I don't think so.
 

« first day (489 days earlier)      last day (4452 days later) »