« first day (607 days earlier)      last day (4324 days later) » 

5:00 PM
@TonyTheLion What can I help in? You seem to have enough capable people in already.
 
7
A: Safer but easy-to-use and flexible C++ alternative to sscanf()

Mooing DuckStick this bit in a new header: #include <iostream> #include <string> #include <array> #include <cstring> template<class e, class t, int N> std::basic_istream<e,t>& operator>>(std::basic_istream<e,t>& in, const e(&sliteral)[N]) { ...

 
It's not like I don't want to help, but I think having too many people on board is not productive.
 
@RMartinhoFernandes but you're the robot, you have special robot skills that no one else has! :)
 
@TonyTheLion I have a full time job, and an upcoming wedding, and Diablo 3, (and nobody trusts my code)
 
DKG
can we make variables of parent less accessible in child class in c++ (we cann't do it in java) ??????
 
5:01 PM
@MooingDuck lol
 
@RMartinhoFernandes Robots are always useful man.
 
@DKG you can only make them accessible protected or public or make them inaccessible, private
no in between
 
@DKG I'm not sure what you're saying, but did you try private inheritance?
 
user784668
@MooingDuck Weddings suck.
 
5:03 PM
@RMartinhoFernandes I'm sure we can come to you for template wankery :D
 
@DKG I think the answer is "yes", it can be done.
 
@RMartinhoFernandes Also, we cannot fit more people on the bitbucket team.
 
What do you mean?
 
only allows for up to 10 peeps
 
5:03 PM
if you have that particular account type
 
DKG
sorry it was methods
 
Is the repo public?
 
you have to pay for teams larger than 5
I'm already paying for the up-to-10-members
 
@DKG works on methods too
 
can't really go up above that
 
5:04 PM
Well nobody has put money into bitbucket right? Lets find another repo
 
Nobody but DeadMG :)
 
It's not too late
 
If the repo is public, I could just have my own fork.
 
@Neil We don't have an alternative hosting solution. That's why I paid up :P
 
@Neil AFAIK, BB is the only somewhat free closed source repo in Hg
 
5:04 PM
@RMartinhoFernandes Don't think you can do that.
 
@DeadMG So, the repo is private?
 
DKG
@MooingDuck But it is not allowed in java and c# , am i right ???
 
@DeadMG how did you manage the vat thing
 
@DeadMG Was I added before the team got full?
 
@RMartinhoFernandes Yeah. Else, you could trivially avoid having to pay in the first place.
@Neil Yeah, you're the tenth member.
@TonyTheLion Dunno. It just stopped complaining.
 
5:05 PM
Ok, that's fine.
 
@DeadMG Whoo hoo!
 
@DKG Please, only one ? per question.
 
DKG
@dr
 
DKG
@Drise what about my answer
 
5:07 PM
@El3ctr0n1c4 Good day!
 
@DeadMG strange
 
@DKG What about what?
 
@drise thanx!
 
@DKG I have no idea, I do C++
 
@DKG I have no idea what you are asking, it's out of my scope of knowledge.
 
5:07 PM
Because it's crystal clear there: #1: We don't care.
"what about my answer" is not a good way to get help here.
 
user784668
As far as I'm concerned, your answer sucks.
 
@Fanael You suck. :D
 
no insulting each other
Only I can insult everyone in this room :P
 
@TonyTheLion s/insult/banter.
 
hey guys
 
5:10 PM
@rubenvb hey
 
I went to SO proper for my bigint printing question.
2
Q: manually printing a N-byte integer

rubenvbWhat is a scalable algorithm to print an N-binary-digit integer manually. I know printf and friends, along with <iostream> (which most likely piggy-backs on <cstdio> have this builtin, but I'd like to do it for an integer composed of N bytes. I have thought about this and googled a b...

 
@rubenvb hey
 
@rubenvb oh was that yours?
 
the only sensible answer seems to be: do math using strings.
 
@rubenvb I give my upvotz
 
5:11 PM
I really wonder why there's no info I can find on the net.
 
Going for lunch, catch you all later.
 
@rubenvb yeah, that is hard, because you have to take the total value and divide by 10, which is a PITA, and slow. Use GMP.
 
@MooingDuck I want.. my.. own.. Real.. based.. on.. my.. own.. Integer. :P
 
@rubenvb first you have to impliment division and modulo then. IO must be based on that.
 
user784668
@MooingDuck Better to divide by the largest power-of-10 smaller than the internal base.
 
5:13 PM
@MooingDuck i'd like a way to just print all digits going left to right. Am I naive?
 
Actually... I wonder how hard it is to convert a hex string to a dec string. That might be massively faster. Maybe.
(btw, printf can't do what you want)
 
user784668
@MooingDuck It's quite hard. It's easier to convert hex string -> number first, and then go number -> dec string.
 
wutwutwut? You really think you can convert a Bigint to Hex, and some readymade print hex as dec will work?
 
@rubenvb yes
 
That all uses int and int64's under the hood.
 
5:16 PM
@rubenvb I dunno, it might be possible.
 
so that would definitely overflow
 
Just handle overflows and carries.
 
user784668
@rubenvb: can't you just use division by 10?
 
@rubenvb Why not just use a bigint library?
Such like the gnu math thingy
 
user784668
@Drise Because he's writing one.
 
5:18 PM
I forgot, people in this room are insane and like to do everything themselves.
 
@Fanael I don't think he's implemented that yet.
@Drise you haven't written a bigint class? I've written 6. (of varying degrees of useless)
 
I wanted to print stuff to check arithmetic stuff
guess I need arithmetic stuff before I can print stuff
division by ten seems like a way to go indeed
why did I not think of that?
 
@MooingDuck Your ternary and istream overload at least now can be deemed not useless.
Or less useless. Idk.
 
lol degrees of uselessness
 
5:25 PM
I considered writing a bigint class that held internal data in a std::vector<unsigned long long>, where each unsigned held values 0-1000000000, which is 50% wasted space, but makes the math and IO really easy.
@rubenvb the first 4 I never got multiplication working right. I didn't get division until the 6th, and it was slow. Division is freaking hard
 
@MooingDuck I've thought of that too. I decided it would waste too much space. Thanks for the support :/
 
@MooingDuck I used to do something like that for programming contests.
You don't waste much time on it, and it's easy to get the math right and then move on to the actual problem at hand.
 
53% wasted space, but it makes the multiplication so much easier
 
I remember space limits used to be on the order of 64MB, so that was not an issue at all.
Usually, anything that made space not an issue unless you got a bad complexity (which is not the case here, since it's a constant factor).
 
user784668
@MooingDuck I just stored full uint32_ts and used the division routine from Hacker's Delight.
 
5:29 PM
I <3 std::vector<bool> optimizations
 
user784668
@Drise pessimizations*
 
@Fanael trade-off FTFY.
 
sbi
@Drise You're a pervert.
 
ok, seeing a pattern in the /10 in binary
don't spoil it for me, unless it's a non-pattern pattern. In that case I'd like to know now.
 
5:32 PM
I don't think there's a simple pattern. Ten in binary is "1010".
 
@rubenvb what? You mean that 1/10 in binary is infinitely repeating?
 
no. I'm writing 8-bit numbers x and their x/10 binary value next to each other.
 
@rubenvb excel makes that really easy
 
@MooingDuck I like my pen and paper.
 
Alright, now my code has loads of warnings in GCC which I am ignoring due to an obsession with performance.
Can a destructor be private? I made my destructor private, but I don't know if that has any effect.
 
user784668
5:39 PM
@MooingDuck Yes. You won't be able to call it (even implicitly) from outside the class and its friends, though.
 
I would guess it can
That'd be interesting to use on classes that needed to be overaligned in C++03, (for SSE)
 
0
A: manually printing a N-byte integer

FredOverflowStep 1: Define a lookup table containing powers of two in string format: const char * const powers_of_two[] = {"1", "2", "4", "8", "16", "32", "64", ...}; Step 2: Write a function that adds two numbers in string format. Step 3: Iterate through the bits in your number and add all the strings c...

 
you just took that idea from either chat or Attila's last sentence! Fraud!
:P
Damn the limitedness of C++ stackoverflow.com/questions/280162/…
 
@rubenvb Are you talking to me? I've used this approach last week.
 
@FredOverflow is it performant vs the divide by ten approach?
 
5:48 PM
@rubenvb I though efficiency was no concern? :) I have no idea how expensive it is to divide by 10.
I cannot imagine how to do arbitrary division on BigIntegers off the top of my head.
 
@FredOverflow well, primarily, it is of no concern. But if someone implemented it, I might as well ask.
 
@rubenvb depends on how you impliment division, but I'd expect Fred's idea to be much faster
@FredOverflow guess, multiply, subtract, repeat. Or do mojo. I looked into the mojo, but it's... confusing
 
Couldn't you "just" divide by 16 and 32 and 256 and 512 and 4096 and 8192 and... and finally add up all those numbers?
 
yay. Input 128 output 128. Niceness. I'll just stick to printing up to Integer<8> and implement the arithmetic with numbers up to 2^64-1.
@FredOverflow the result is impossible to represent.
 
@rubenvb Why? Dividing by powers of 2 is trivial.
 
5:52 PM
I hate complementary assignments
 
@ManofOneWay What is that?
 
@FredOverflow the sum is irrepresentable
 
Again, why? Just add a bunch of numbers, what's the problem?
 
you mean in string?
 
No, bits.
 
5:53 PM
cause my Integer<9> does not fit in a native data type.
 
@FredOverflow I'm talking about school assignments =)
 
so "adding everything" would overflow.
 
Of course you need to implement addition for your BigInt.
@ManofOneWay Oh, I thought you meant something like a = !a.
 
@FredOverflow Beware. Statements like that might damage the robot when he tries to read it.
 
5:54 PM
@FredOverflow Btw, do you have the "overview of the new c++ (c++11)" by Scott Meyers?
 
@ManofOneWay Probably not.Why do you ask?
 
@StackedCrooked What? Toggling a boolean?
@ManofOneWay I do.
 
I want it and the only way I can get it is by paying 30 dollars for a pdf
There is no physical copy as far as I know
@RMartinhoFernandes Do you have the pdf?
 
@RMartinhoFernandes It could be interpreted as a value definition.
 
@ManofOneWay Yes.
 
5:56 PM
@RMartinhoFernandes Can I get it from you?
 
@ManofOneWay You could buy the PDF and then have it printed professionally in a copy shop.
 
@FredOverflow Which would cost an extra 30 dollars
 
I'm pretty sure it's worth it.
 
Get an ereader. Prosper
 
@ManofOneWay Have you tried Google?
 
5:58 PM
I have
:(
 
I guess you're out of luck then.
 
I guess so
 
// is this anti-idiomatic behavior for iterators? (not using an end-iterator, that is)
iterator_t<T> it(my_container);
while (it) {
    std::cout << *it++ << std::endl;
}
 
Empty Base class optimization doesn't seem to work how I thought it does
 
@StackedCrooked It's so idiomatic, the standard explicitly requires it.
@ManofOneWay Ping me to my mailinator box (see my profile).
But it should be while(it != end), obviously.
 
6:06 PM
@StackedCrooked call it something else if it doesn't work like standard iterators.
@StackedCrooked ranged_iterator?
 
@StackedCrooked while(it) will not do what you appear to think it does.
 
@FredOverflow it can
 
@FredOverflow AFAIK I didn't think this would even compile.
 
@StackedCrooked Where did you get this code from?
 
@StackedCrooked depends on the type of iterator_t
 
6:08 PM
@FredOverflow I made it up. I was wondering why we always need to compare against the end iterator. And I wondered, if I designed something like this, would it be anti-idiomatic?
 
Because iterators suck.
2
Because, given an arbitrary iterator, there's nothing you can safely do with it.
 
@RMartinhoFernandes Well, you could compare it with itself.
 
Other than output iterators, they always work in pairs. Which is why ranges are better.
 
@FredOverflow How useful :D
 
@StackedCrooked I have never seen this before in my life, and I've read at least a dozen C++ books. Hell yeah it would be anti-idiomatic.
 
sbi
6:09 PM
> The answer to "How do I learn PHP?" is always "Through a series of very unfortunate events, starting with asking that very question." — @Tim Post
 
hmm, I can't debug my TMP code. I assume nobody else wants to dig through my bad ideas? ideone.com/ieFNr
 
Oooh, shiny TMP.
 
by the way
I'm not a master of the new C++11 SFINAE
 
sbi
@MooingDuck How are we supposed to understand your code, if you yourself do not understand it?
 
can I do
 
6:12 PM
@RMartinhoFernandes glaring TMP
 
        template<typename T, typename = std::enable_if<std::is_base_of<Control, T>::value, std::unique_ptr<T>>::type>
             std::unique_ptr<T> CreateControl() const;
or is it supposed to be simpler/harder?
 
@DeadMG Yes, but you can do better.
 
@RMartinhoFernandes Show me?
 
@RMartinhoFernandes Not sure if my expression templates are technically TMP or not, but they won't compile.
 
6:13 PM
#define take
#define with &&
#define in ||
^ O HAI?
 
@DeadMG I thought you were uberconfident in your C++ mastery?
Oh, that was yesterday.
 
@rubenvb I am.
 
@MooingDuck Can I trust the errors on ideone (i.e. features and shit)?
@StackedCrooked He's gone rogue.
 
some of the new C++11 features I am inexperienced with, since this is my first time with a compiler that can do them
 
@DeadMG you lie:
1 min ago, by DeadMG
I'm not a master of the new C++11 SFINAE
 
6:14 PM
@StackedCrooked long story, I don't like those earlier
 
@MooingDuck "earlier"? Or "either"? I hope the latter.
 
@RMartinhoFernandes Does that have a form without all your own libraries?
 
@RMartinhoFernandes oh, those are different errors. curses
 
@DeadMG Yeah, the actual thing is just four or five lines. I can get you a standalone thing if you gimme a couple minutes.
 
nah, it's OK
I don't need it
 
6:16 PM
@RMartinhoFernandes: Here's teh errors: ideone.com/tr3Iv :(
 
no, wait, I do need it
 
3
Q: 'Freezing' an expression

Ben StottI have a C++ expression that I wish to 'freeze'. By this, I mean I have syntax like the following: take x*x with x in container ... where the ... indicates further (non-useful to this problem) syntax. However, if I attempt to compile this, no matter what preprocessor translations I've used to ...

 
@RMartinhoFernandes Done :)
 
@DeadMG I think this is all you need: ideone.com/zGMkC
There's a workaround for a clang bug, but you're using GCC, right?
 
yeah
 
@ManofOneWay Ok, gimme a while, I don't have it on this box. I'll need to download it again, which means coaxing google to find the right e-mail.
@StackedCrooked I think it's nice already.
 
@RMartinhoFernandes Doesn't have constructor yet.
 
Inherit one!
No compiler supports that :(
 
And the relation between x, y, z and the tuple types is not really "static".
 
What do you mean?
 
6:26 PM
I mean I could make the enum a, b, c, d and meanwhile a use a tuple<int, int, int>. This doesn't immediately trigger a compiler error. (It will later when using.)
Ah well.
Perhaps it's nice as it is, without anything added, like you say.
 
@StackedCrooked static_assert if you're going to generalize it.
 
@rubenvb static_assert on what?
 
Actually the original goal was to define a struct that is "automatically" serializable.
 
An enum can have all values of the underlying type, not just the enumerators.
This is just about giving them names.
The error will show up as soon as you use it anyway.
 
@RMartinhoFernandes That's right. Good.
 
6:31 PM
@RMartinhoFernandes hmm, enum and parent tuple size :)
which is not quite possible
 
@rubenvb Enum size is 4. Or implementation-defined.
It's not the number of enumerators.
Holy limes, this is horrible.
 
Doesn't look like a joke. OMG:
 
@RMartinhoFernandes Isn't the whole thing about P = NP-Complete though? Traveling salesman is NP-Hard.
 
@Pubby The thing is, if P = NP, we can solve NP-complete problems in polynomial time, which means we can solve many, many hard problems in polynomial time.
The decision version of travelling salesman is NP-complete.
 
6:46 PM
Oh, I forgot about the decision version
 
@StackedCrooked Recurse with the parameter to std::get starting with sizeof...(args).
 
@StackedCrooked Indices trick.
 
6:59 PM
What does { ar & get<I>(t)... } expand to?
 

« first day (607 days earlier)      last day (4324 days later) »