« first day (699 days earlier)      last day (4253 days later) » 

5:00 PM
0
Q: Scrabble Point Counter

RyanI am working on a scrabble program that generates 7 letters, then allows the user to enter words and see if they are valid and what the point value would be. As soon as I started doing the values is when I started having problems. I am calling the function wordvalue like this, and wanting to st...

I'm sure there's a better way than using case statements here?
 
I must admit, it is nice to see everyone back to their old selves.
 
I just received this mail. WTF
 
All french to me broski
 
@Drise What matters is the name of the expeditors. The content really doesn't.
 
5:02 PM
@kbok I know
 
@kbok It's obviously spam.
 
@kbok That's a very quick sex change.
 
@R.MartinhoFernandes It's from my former uni
 
@EtiennedeMartel Expert, even.
 
Not very secret, though.
 
5:05 PM
Gotta go. Friday night !
 
@TonyTheLion Oh, btw, I'm accepting suggestions for a next topic.
 
0
Q: How prefix/postfix operator works in assembly level?

Debadyuti MaitiI've found the following code snippet producing different outputs when tried with Turbo C++,Dev C++,& Java. int i=3; i=i++ * i++ * i++; int j=++i + ++i; As the definition says in various books, the output should be i=3*4*5=60 & j=61+62=123.In fact that is the output when tried in Java....

close votes!
and goggles
 
i=i++ * i++ * i++; is Undefined behavior. That could make you pregnant! Don't do it. — Tony The Lion 37 secs ago
 
@R.MartinhoFernandes Something with templates?
 
UB pregnancy, that sounds fun :D
 
5:10 PM
lol
0
Q: why python is faster than c when concating two strings?

Marcuscurrently I want to compare the speed between python and c when they're used to do string stuff. I think c will give out a better performance than python will, however, I got a total contrary result. so here's the C program: #include <unistd.h> #include <sys/time.h> #define L (100*...

hmmm
 
@TonyTheLion Yes, an array of 26 ints or chars with the tile value of each letter in each element.
 
yes
what I thought
 
> Classes that have custom destructors, copy/move constructors or assignment operators should deal exclusively with ownership. Other classes should not have custom destructors, copy/move constructors or assignment operators.
I think that this is a little strong
 
is it possible to use cppdepends without having dang installed?
 
> Smart Pointers and Ref Counting in Java
What?
 
5:14 PM
"Should" is strong?
@Cheersandhth.-Alf Your kerning looks wrong :)
 
well, primarily, you don't indicate any acceptable cases where this does not apply.
one of the primary uses I've seen for custom destructors is to notify other objects of our destruction- but not owning and aren't even values.
 
@R.MartinhoFernandes It can lift 60kg!
 
@DeadMG Well, it should really be called "the Guideline of Zero", but it doesn't sound as catchy.
 
i'm just asking because cppdepends is based on dang and as far as i know dang is pretty useless in windows (no support for exceptions except maybe with special build)
so, anybody here using cppdepends in windows?
 
Basically, I'll refer anyone who comes up with a counter-example to a famous quote from Barbossa in Pirates of the Caribbean. :P
 
5:16 PM
You don't need exceptions to parse the source and extract dependencies.
@R.MartinhoFernandes What quote?
 
> And thirdly, the code is more what you'd call "guidelines" than actual rules. Welcome aboard the Black Pearl, Miss Turner .
 
Integer i(2); i = 3;
^ Exception to the rule of three or zero.
Doesn't need destructor.
 
Oh that
 
@StackedCrooked HOw is that not part of the rule of zero?
 
@StackedCrooked What about that.
 
5:19 PM
@StackedCrooked What.
 
I don't really know what the rule of zero states.
 
FTR, a conversion constructor is not a copy constructor (well, maybe it can be, but let's not get bogged down in details).
 
@StackedCrooked conversion constructors don't count
 
@R.MartinhoFernandes The assignment operator is not a conversion constructor.
 
@StackedCrooked No destructors, copy constructors, assignment operators, move constructors, or move assignment operators.
 
5:20 PM
@StackedCrooked It's also not a copy assignment operator.
 
@StackedCrooked it calls the conversion constructor, then the default assignment. You don't need to code anything special.
 
No copying or moving boilerplate, that's what.
 
@MooingDuck But the constructor is explicit.
 
Wut.
I think you're really confused.
 
You suck and you should feel suck.
 
5:21 PM
You're terrible.
 
@StackedCrooked ah
 
The point of rule of zero is no boilerplate.
 
something operator=(int); is not a copy/move assignment operator.
 
At least I think, because I didn't really read the post.
 
@R.MartinhoFernandes That is what I am saying.
 
5:22 PM
But that's logical and robot is logical so.
 
@StackedCrooked So?
@CatPlusPlus Yeah, that's it.
 
Logical Cat is logical.
 
But that's not related to rule of anything.
 
What does the rule of three state?
 
5:25 PM
@StackedCrooked The rule of three also only deals with copy assignment.
 
If you need a destructor, copy constructor or copy-assignment operator, you probably need all three.
 
Crap. Copy-assignment.
Ok. I shall dig a hole now.
 
Go dig
 
0
A: Why is Python faster than C when concatenating two strings?

Cheers and hth. - AlfAs I'm writing this answer your code has Undefined Behavior. That means that it's meaningless. Or in other words, balderdash. The experiment, with garbage input (your code), produces garbage output. This is known as GIGO (Garbage In, Garbage Out). #include <unistd.h> #include <sys/t...

^ I thought it would be nice to find duplicate of the question, but it turned out, question was just nonsense.
 
Where's the UB?
 
5:27 PM
someone already tried The C++ Standard Library: A Tutorial and Reference C++11 edition?
 
@bamboon No.
 
Sorry I don't see the UB either
 
As I write this comment, your answer has unexplained technical assertions. That means that it's not helpful. In other words, useless. — Josh Caswell 2 mins ago
 
lol
He edited it. Doesn't show up here though.
 
5:32 PM
One exception to the rule-of-three (or zero) might be that if you want the class to be copyable but you have a member variable that is move-only (e.g. a mutex). You could then define a copy constructor that copies all members except the mutex member (which is default initialized). Copy assignment would assign all members except the mutex member.
 
@StackedCrooked or make a psudo_copy_value<T>, and use that for the mutex. (better name pending)
 
@StackedCrooked Capture that behaviour in a separate reusable class!
 
Then psudo_copy_value breaks the rule of three.
 
It's not a hard rule. But if mutex can be default-initialised when copying, then why isn't it copyable?
 
No, it doesn't.
 
5:34 PM
@StackedCrooked no, because the entire point of that class is to manage a resource. That's part of the rule of zero.
 
@StackedCrooked "I need different ownership semantics" is not an exception to the rule of zero.
"I mingled different ownership semantics with other concerns" is a violation of the rule of zero (and SRP).
 
@StackedCrooked That's also why shared_ptr isn't a violation of the rule of 0
 
@MooingDuck Does the rule of three state an exception for small classes that manage a resource?
 
@StackedCrooked The rule of zero says a class who's entire and only point is to manage a resource is exempt from the no assignment/destructor/etc stuff.
@StackedCrooked if it has a destructor/assignment, that must be the entire and only point of the class
 
If you have to do one, you have to do all of them.
That doesn't mean that you can't ever do a special member.
 
5:40 PM
@MooingDuck Link?
 
Isn't it obvious.
You have to have primitives to build no-boilerplate code.
 
@StackedCrooked rmartinho.github.com/2012/08/15/rule-of-zero.html "Classes that have custom destructors, copy/move constructors or copy/move assignment operators should deal exclusively with ownership. Other classes should not have custom destructors, copy/move constructors or copy/move assignment operators."
@R.MartinhoFernandes: Rule of zero should be reworded to be "copy/move assignment operators"
 
@CatPlusPlus I'm not disagreeing with that. Only saying that it would count as exception to the rule (if not included in the rule).
 
@MooingDuck Yeah, I realized it's formulated in an ambiguous manner.
I will edit in the weekend.
 
@R.MartinhoFernandes want me to comment to it doesn't get forgotten?
 
5:43 PM
@MooingDuck Is there a source that has more authority on this matter. (No offense to @R.MartinhoFernandes.)
 
At this point anyone can claim authority on C++11. In fact, I am an authority on C++11.
 
@StackedCrooked I don't think so, I think we (as an SO community) made it
 
@StackedCrooked No. It's just a particular instance of the SRP. I came up with the name in this room one day when people where discussing rule of 3 vs 5.
 
What do you mean more authority.
 
Wait, the name "Rule of Three" was invented by the regulars here?
 
5:46 PM
No.
 
No, rule of zero.
 
Rule of zero is mentioned in C++ Design Patterns
 
At first glance it's the same.
 
The title makes me want to burn that book.
 
Erm, Internets really sloooow.
 
5:48 PM
Black Mesa is unpacking. :3
 
other than that one book, I can't find any reference to the "rule of zero" that isn't either RMartinho or SO.
 
@MooingDuck C++ Design Patterns and Derivatives Pricing? Wow. That's... quite a weird title.
 
So what?
 
@R.MartinhoFernandes I hadn't seen the full title. That is quite weird.
 
So this is the way to write the answer without that stupid humungo switch statement.
0
A: Scrabble Point Counter

ChimeraI know you've already accepted an answer, but I wanted to show you a way to avoid having to write that lengthy switch statement. #include <stdio.h> #include <string.h> #include <ctype.h> /* prototypes */ int wordvalue (char *userword); unsigned char letterValue( char letter );...

Silly silly people.
 
Xeo
6:00 PM
@MooingDuck Interesting book, from the two pages I saw I like it
 
super() is Java-specific right? I've never heard of it in C++.
 
that's what I thought
 
I sometimes create a typedef to the base class called super or base. This allows me to call the base constructor with super() or base().
 
6:10 PM
@Mysticial correct
@StackedCrooked I usually call it parent_type, but yeah.
 
60
Q: Using "super" in C++

paercebalMy style of coding includes the following idiom: class Derived : public Base { public : typedef Base super; // note that it could be hidden in // protected/private section, instead // Etc. } ; This enables me to use "super" as an alias to Base, for exa...

 
interesting
 
According to the accepted answer super could (almost should) have been in C++.
 
I don't like that word
reminds me to much of shitty Java
 
6:12 PM
Programmers need to be rational.
 
Spotify Y U CENSOR LYRICS
 
@StackedCrooked there's no reason. Add a private typedef and you're done.
 
@MooingDuck A typedef introduces duplication. If I change my base class then I also need to change my typedef. That way uncool.
 
@StackedCrooked true
 
// I've experimented with this, but it leads to certain problems..
template<class Base = MyBase>
struct MyClass : public Base {};
 
6:15 PM
Ugh.
 
pretty
 
So a private typedef is still the way to go. I guess macros could help, but they have their own problems. So a little manual labor seems unavoidable.
@Mysticial Be careful with what you say here :)
 
for (initialization; condition; inc/dec)
is the condition evaluated only once?
 
I haven't toyed with: struct MyClass : Base<MyClass>::Type {}; . The manual labor involved here probably outweighs the advantage with non-duplication.
 
Can somebody clarify for me what a ā€œconversion constructorā€ is in C++11? Why is a copy non-explicit constructor called ā€œconversion constructorā€?
0
Q: can copy constructor be a conversion operator?

WhoamiConsider the following code. #include <iostream> using namespace std; class Test { private: int x,y; public: Test () { cout <<" Inside Constructor "<<endl; x=100; ...

 
6:19 PM
That would be an infinite loop if it was evaluated only once. It clearly must check to see if it's done every time through the loop.
 
@StackedCrooked Make it an alias.
 
@KonradRudolph Why limit the question to C++11? Is there a difference with C++03?
 
@KonradRudolph There's no conversions in that code at all.
 
@R.MartinhoFernandes As opposed to using a typedef?
 
@StackedCrooked I donā€™t know, to be honest ā€“ Iā€™ve never encountered the terminology, is all
 
6:21 PM
@StackedCrooked No, I mean Base<MyClass> instead of Base<MyClass>::Type.
 
@MooingDuck Thatā€™s what I thought but look at the answer citing the standard
 
@KonradRudolph Here is Microsoft's definition. For what it's worth..
 
Xeo
@KonradRudolph Because a non-explicit copy ctor can be used for implicit conversions.
Wait, that doesn't make much more sense
 
@Xeo why copy con though?
 
Xeo
I think it's just to differentiate between explicit and non-explicit copy ctors
 
6:22 PM
you need a different argument type to convert from
 
@KonradRudolph huh, weird
 
Xeo
ask @Luc, he had that is_constructible and is_convertible_from thing that is used for those
 
@StackedCrooked Yes, thatā€™s the definition I know, but thatā€™s not what the question/answer is about
 
@KonradRudolph It's not C++11 terminology.
Well, it's not new in C++11.
 
@KonradRudolph oh! A question linked to in the comments clarifies: base a = my_derived; It does do a conversion in that case.
 
6:26 PM
> A constructor declared without the function-specifier explicit that can be called with a single parameter specifies a conversion from the type of its first parameter to the type of its class. Such a constructor is called a converting constructor.
12.3.1 Conversion by constructor [class.conv.ctor] (in C++03)
 
@MooingDuck Ah, true.
 
@TonyTheLion That might explain some things.
 
Rapist!
 
6:31 PM
+1 This question taught me something new. I'm not sure exactly what it is, only that a C++ string implementation should better go all the way down to memcpy in order to get acceptable performance. Sorry for misreading the code and posting nonsense answer (thinking the question was nonsense). — Cheers and hth. - Alf 51 secs ago
^ There is some amazing inefficiency in strcpy and strcat, with both msvc and g++, even in ubuntu. huh. how come.
it's, like, unbelievable
 
Hating CoffeeScript is like hating Apple. Its popularity implies you have no *taste* in programming languages.
I donā€™t know what that means but it sounds incredibly stupid
 
Yeah, it does.
 
It seems that is going away.
 
Sounds like "CoffeeScript is popular, if you hate it then you have no taste"
and yeah its a dumb statement
 
shitting is also popular. everybody does it. must be fun/good/quality
5
 
6:36 PM
@Chimera yeah, I saw that meta post... :(
 
@Borgleader See, I understood kind of the opposite, but whatever way you dice it itā€™s dumb
 
@Cheersandhth.-Alf So, one point for length prefixed strings?
 
I had a bronze badge in too... :(
 
i don't know
 
@Mysticial :-(
 
6:41 PM
i think it has to do with checking of loop conditions, overlap etc. perhaps being done at too low level (inside loop instead of outside).
 
looks like someone already removed the tag off the matrix question... meh
 
Why are they removing #homework and Mysticial you have like so many bronze badges anyway...
 
@KonradRudolph It's another case of argumentum ad populum.
 
27
Q: Trogdor ate my homework (tag)!

Tim PostThe result of a rather lengthy discussion concludes with the homework tag needing to go away on Stack Overflow. As far as tag burninations go, this is quite large, with over 20,000 questions to examine. When the tag is removed, it will be blacklisted - banished to the outer realms and never spoke...

I don't care much about the badge. But I did have the highest voted answer in the tag...
 
hi all
 
6:43 PM
That was interesting while it lasted...
 
my brother just told me that hardly anybody still codes in C++ (at least not new projects). I'm an amateur, but some here should be able to give me some arguments ...
 
sbi
@TimPost: "If you don't want a fully vetted, complete and testable answer, Stack Overflow is not the place to ask." So Stack Overflow isn't a place for asking homework questions anymore. I find this a very sad state of affairs. — sbi 23 secs ago
 
@Walter There's a Chinese saying called "Frog in a well" which can be used to describe your brother.
 
@Mysticial How high?
 
@sehe The matrix question.
It turns out that the OP actually grabbed it from a homework problem.
 
6:47 PM
@Mysticial umph -- I'm not Chinese
 
He admitted it on reddit and someone added the tag to the question.
 
@Walter: AFAIK any AAA game coming out these days is C++
 
C++ is in 8th place at SO (followers to a tag)
 
so id say your brother is plain wrong
 
@Walter It basically means, "a frog in a well hasn't seen the true size of the sky". In other words, the frog hasn't seen what the world is like.
 
6:48 PM
@Mysticial you're Chinese?
 
@Mysticial I like the saying (never heard it before)
 
yes, makes sense
 
@Walter Cantonese to be specific.
 
@Borgleader can you support this with some evidence of arguments?
 
It's a Cantonese saying, but I assume it also reads well in Mandarin.
 
6:50 PM
I interned in a video game company on a AAA game and it was C++
 
my brother works for a company which writes code for Deutsche Bank
 
and i spoke with my colleagues, the other games they've worked on, also C++
evidence enough?
 
@Borgleader what does "AAA" game mean?
 
@KonradRudolph My dad used to use it on me a lot whenever I got a little too confident.
 
Big budge games (Halo 4, Borderlands 2, ...)
*budget
 
6:50 PM
actually, I was telling him that the game industry certainly will be C++
 
@Borgleader Edit using the up arrow key
Sep 9 at 11:45, by daknøk
If you are new here, please read the newbie hints right away, and only post here afterwards. Thank you.
 
@Borgleader would the engine & stuff be re-used for other games?
 
Oh would you look at that o.O handy feature.
The project I worked on, everything was C++ (except for external tools for editing levels, but the core of the game, the engine and all, it was C++)
 
@Cheersandhth.-Alf It is
 
@Walter Iā€™m working in big data science (bioinformatics), it certainly gets used extensively there for high-performance stuff
 
6:54 PM
yes high performance, I can believe (that includes games & science)
but what about database applications --- that are a lot of programs used in industry
 
Parts of the engine can be re used yes
 
@Walter Thing is, C++ is complex, even for people who know it so if you can get away with something more convenient ā€“ such as in most database-driven applications ā€“ you will use something else
like C#
or a dynamic language (Ruby, Python)
 
@KonradRudolph good point. Yes I think that's a problem with C++: because it is so powerful (has low-level capacity and high-level abstraction), it is bound to be rather complex -- there is not one person who really knows all of it inside out, not even BS.
 
Yeah, bullshit (BS) doesn't really know C++.
 
@TonyTheLion What do you mean? I think Spotify just carries what the labels publish
 

« first day (699 days earlier)      last day (4253 days later) »