« first day (527 days earlier)      last day (4424 days later) » 

8:00 PM
@DeadMG: Are we talking about things like prvalues and xvalues?
 
yeah
 
@Beginnernato no. <removed stupid link>
 
> The whole massacre began with the move semantics. Once we have expressions that can be moved and not copied, suddenly easy to grasp rules demanded distinction between expressions that can be moved, and in which direction.
149
Q: What are rvalues, lvalues, xvalues, glvalues, and prvalues?

James McNellisIn C++03, an expression is either an rvalue or an lvalue. In C++11, an expression can be an: rvalue lvalue xvalue glvalue prvalue Two categories have become five categories. What are these new categories of expressions? How do these new categories relate to the existing rvalue and lva...

 
It's because there are several combinations of choices of "identity"/"no identity" and "movable"/"not movable"
 
8:06 PM
Well I'm trying to implement the following .. stackoverflow.com/questions/9853402/… ... and trying to figure out how to differentiate from string and number ? .. some dude suggested strtol but i can't find that helpful :S
 
#if !defined( CPP_DECLARE_UNUSED )
#   define CPP_DECLARE_UNUSED( argName )    \
        (void)argName; struct argName
#endif
^ The simplified version. It's exactly as it was before I mindlessly adopted the SO answer's code.
 
Back to the old one?
 
What's struct doing there, anyway?
 
8:08 PM
@CatPlusPlus It's to hide the name.
 
And that's helpful because?
 
@RMartinhoFernandes all the complication in the SO answer was to support sizeof, and void argument to sizeof. but sizeof Does Not Work for warning suppression in Visual C++.
 
Because removing the name of the parameter from the signature is way too expensive...
 
@Insilico That question doesn't do such a good answer of "Why"
 
8:09 PM
@CatPlusPlus The reasoning is that if it's unused, you don't want to use it accidentally.
 
@CatPlusPlus It enforces non-usage.
 
I'm sorry, but lol.
 
@CheersandhthAlf What about operator void?
 
If it's unused then it means it's unused.
 
8:09 PM
@Insilico I can understand why they call C++ "Expert Friendly" :)
 
I thought that was the point.
 
void whatever(int unused) -> void whatever(int)
 
@RMartinhoFernandes huh?
 
And what @EtiennedeMartel says.
 
@CheersandhthAlf (void)x invokes operator void if one exists, no?
 
8:10 PM
Also, __attribute__((unused)).
Not that it's very helpful.
But sure, weird hacks are nice, too.
 
@RMartinhoFernandes hm, i haven't had that problem...
 
@RMartinhoFernandes So it can have side-effect? Yikes. I've used it to silence compiler warnings.
 
@EtiennedeMartel That's what I use.
 
That's what you get for silencing warnings instead of fixing them.
 
8:12 PM
I use #pragma warning to disable compiler warnings.
 
bool result = foo();
assert(result);
(void)result
In release mode a warning would be triggered because result is unused.
 
assert(foo())?
 
@DeadMG: assert() expands to nothing in release mode
supposedly foo() has side effects
 
8:14 PM
I know
then why the hell wouldn't you assert in foo itself?
 
The hell I know, go ask @StackedCrooked
 
indeed
 
bool flag_is_set = is_flag_set();
Depending on context it must or must not return true.
 
@StackedCrooked You can assert(is_flag_set()) for that.
Don't tell me you have something like is_flag_set with side-effects.
 
8:15 PM
You can use BOOST_VERIFY which is like assert() but expands its parameter out at release mode
 
Ok then.
 
assert is not for error-checking.
:.
 
int result = get_last_result();
assert(result > prev_result);
Is this so unreasonable?
 
@StackedCrooked Well, kinda, yes.
you're still keeping the result of the geter around for no reason beyond the assert
 
@CatPlusPlus I use it for finding faults earlier in the program. For error checking I use exceptions.
 
8:16 PM
@StackedCrooked Presumably the code will use get_last_result for something.
 
You can expand assert to if ((expr)) {} in release.
Compiler will remove the branch, but shouldn't complain that variable is not used.
 
I find it weird that the program depends on some result that has no effect on it.
 
can an array store both strings and ints ? ... if so how would i initialize that ?
 
std::vector<boost::variant<std::string, int>>
Oh wait, C. Then no.
 
yea lol ..
 
8:18 PM
if (is_coding_in_C()) { you_are_fucked(); }
 
Or maybe union. With manual tagging.
Just use C++ dammit.
 
using C is like using a Singleton- I've no sympathy for your problems, because the solution is obvious- just don't use it in the first place.
 
// Complete fuckery, don't ever use ever
struct string_or_int
{
    union { char* c, int i };
    bool isInt; // true if i is valid, false if c is valid
};
 
i wish i was learning C++ ... i'll be learning that nex year :(
 
ah
so some other fucker made you do it
well, go tell him where to shove it
 
8:20 PM
but apparently if i learn C, i should be good with all the other languages ?
 
bwahahaha
 
@Beginnernato: Unfortunately, no.
 
aww they lied to me :(
 
C is a pile of worthless junk, and absolutely nothing else is coded like C
 
8:20 PM
C != C++ by a long shot
 
not even C++
let alone, like, every other language, ever
 
Unfortunately, if you learn C then go learn C++, you will end up having to unlearn C to learn C++.
 
C is a terrible language to start with.
 
I'm happy with "worthless junk" as my description
 
C is a terrible language to do anything with.
 
8:22 PM
C something something something terrible something something.
 
I read an article saying that "Learning C helps you learn more recent languages like C++" or something like that.
Thinking to myself: Why not just learn C++ first then, if it's more recent?
 
yeah
 
C isn't terrible, it's just obsolete
 
(this was before I knew anything about computer programming, btw)
 
@Pubby Those are the same thing.
 
8:23 PM
COBOL isn't terrible, it's just obsolete.
 
COBOL was terrible to begin with
 
You can't spell COBOL without C.
Or something.
 
PHP isn't terrible, it's just, .. Nah, it's terrible.
7
 
KOBOL?
 
COBOL would've been okay if it wasn't designed for people who think that programming should be easy
 
8:24 PM
Too much BSG.
 
@CatPlusPlus ⅭOBOL.
 
You and your charmap.
 
15
A: Can the dollar sign be someone referred to c++ pointers?

In silico Since PHP derives from C++... Stop. This line of thinking will get you nothing but pain and suffering. Perl, LPC, Lua, Pike, Ada 95, Java, PHP, D, C99, C#, and Falcon are all derived from C++ as well, for some definition of "derived", and I can guarantee you they act nothing like C++ and are...

 
Yes, we've seen that.
 
Yup, PHP is terrible.
 
8:25 PM
It's eyebleach again.
I hope you're happy.
Gah.
 
@CatPlusPlus: Yes. I am very happy thank you very much.
 
This is RVO but not NRVO, right? return std::pair<double, double>(root1, root2);
 
Yes, that would be RVO
 
Does the pair have a name? No.
 
@CatPlusPlus I'm going to drop this here while I can claim it's related to the discussion at hand. tvtropes.org/pmwiki/pmwiki.php/Main/BrainBleach
 
8:27 PM
(Assuming your compiler isn't stupid)
 
Some guy said it was NRVO in this relevant article to C vs C++: blog.feabhas.com/2012/03/on-the-evolution-of-programming-style
 
@RMartinhoFernandes That's what she said.
 
Screw you @RMartinhoFernandes
 
Btw, even if you read that one before, you should check it. They changed things in it.
I know that for a fact.
 
Any article about C vs. C++ is useless.
Might as well put in 200 point font
C is nothing like C++, stop trying to compare them
 
8:28 PM
It's not really a comparison, it just shows the evolution.
 
Ah okay
But my point still stands. :-)
 
Maybe @Konrad should make some "C is not fucking like C++" slides.
 
Make sure you put it up on a tinyurl or something like tinyurl.com/dont-use-pointers
> Hey, thanks for showing us all how C all the way through to C++ suck.
 
Is there any point to using auto -> without decltype? Like what's the point of this? auto findRoots() -> tuple<double, double>;
 
Perhaps the author prefers that?
To showcase the alternative return type syntax?
 
8:32 PM
Perhaps the guy has a math background.
 
say i have input's that is a name -string and a score -int ... Like "Jenny 10" .... i want to store "Jenny" and 10 in an array ... not possible? ... or do i need to store in seperate array's ?
 
Also, when should uniform initialization syntax be used? stackoverflow.com/questions/1863784/…
 
@Beginnernato: Use a struct
 
@Beginnernato a struct is a way of grouping related variables.
 
Then have an array of score_entrys.
score_entry entries[64]; // or something
 
8:34 PM
@Insilico wouldn't i need to use malloc and free ...? im not allowed to use any heap storage
ohhh i see
 
@Beginnernato: If name points to a constant string
Then you don't need to malloc() it
Like:
 
You need to dup it if you want to modify it, though
 
score_entry se;
se.name = "Jenny";
@CatPlusPlus: Correct.
 
ahh okay
 
Also, don't ever assign a literal to char*.
C has const.
 
8:35 PM
@RMartinhoFernandes Didn’t I already? ;)
 
struct score_entry
{
    const char* name;
    int score;
};
Someone bin that last code post with the non-const char*
 
@KonradRudolph Oh. Good point.
 
I hate C solutions
 
Happy to oblige.
 
I miss std::string and std::vector<score_entry>, for example
 
8:38 PM
hmmm so from input i get "Jenny" and 10 since i used a space ... would the input be different, how would i access "Jenny and 10" so i can store them properly ?
 
@RMartinhoFernandes In all honesty though, I barely know C … certainly not enough to draw a comparison or to criticise it constructively. I have seen some very, very good C architectures. I’m happy that I don’t have to write code like this but at the same time I can appreciate that C allows you to write well-specified, modular, abstract, object-oriented code
 
@Insilico i have this readstring function ideone.com/jTq3l ... that control's my while loop? ... how would incorporate this ? O_O
 
@Beginnernato: Oh I didn't see that
In that case you need strdup() and free() to store the strings in the structures
 
@Beginnernato you can't use the heap? Were you given a maximum length for names?
 
@MooingDuck yea 20
 
8:47 PM
struct score_entry
{
    const char name[21];
    int score;
};
 
@Insilico That uses the heap
 
Easiest thing to do is read the line into a char array of length 40 or so. THen copy the letters into name until the first space. Then use atoi on what's left and store the result in score
(unless someone knows a better way to read until the space, which is likely)
 
@RMartinhoFernandes: Yeah, I forgot about that
 
@MooingDuck how would i take input and store this exactly ?
 
@Beginnernato: To access members in a structure:
arr[0].name = // name
arr[0].score = // score
 
8:51 PM
@Insilico mhm ... but when i input like "Jenny 10" .... my input would be seperated to string -"jenny" and score 10 ... how would i store this in the struct ?
int -10*
 
Wouldn't scanf("%s %d" be enough?
 
@RMartinhoFernandes "%20s %d"
 
@RMartinhoFernandes would that mean i shouldn't use my readstring function?
 
Oh, haven't seen that.
 
8:55 PM
@Beginnernato your readstring function looks complicated
 
yeaa :(
 
@RMartinhoFernandes scanf("%s") is dangerous.
 
This is neat:
 
I got this for him, but there appears to be a runtime error. ideone.com/CTebL
 
8:58 PM
Sigh, people.
@MooingDuck Well, there's no input...
 
Yeah, I saw that.
 
@RMartinhoFernandes even so, it returned -1, instead of 1
 
I didn't read the book, but it seems the character was black in it.
 

« first day (527 days earlier)      last day (4424 days later) »