what's the difference between
template<typename T>
auto add1(const T& a, const T& b)
{ return a + b; }
and
template<typename T>
auto add2(T a, const T& b)
{ return a += b; }
?
@mew27 understandable, after all javascript is C for pussies...
1 + {} = "1[Object object]"
They're two different animals. C was developed for minicomputers that had teletypes and terminals connected to them. It was created so programmers didn't have to write everything in assembly language.
Javascript was written a couple decades later, shortly after the browser was invented, when personal computers were just beginning to become connected via the World Wide Web (WWW). They made Javascipt to run in the client browser so that web pages could be more interactive.
(But perhaps you just make the comparison so you could make the joke. :)
@iron_bug to you any quirk of C is the word of god, so not sure what to argue here... just look up "quirks of C language"? Plenty of results.
Since we're doing arithmetic here suffice it to say:
unsigned short * unsigned short = insta-undefined-behavior-trollface
Also 2[a] is definitely syntax sugar for puppies only, I agree.