In Stroustrup's example, what does this colon mean in `return 1 : 2`? It's not a label or ternary operatorWhat does the explicit keyword mean?What does “static” mean in C?What does map(&:name) mean in Ruby?What does the question mark and the colon (?: ternary operator) mean in objective-c?What does the star operator mean?What does int argc, char *argv[] mean?What is the meaning of prepended double colon “::”?What does “dereferencing” a pointer mean?What does T&& (double ampersand) mean in C++11?C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?
What are the advantages of luxury car brands like Acura/Lexus over their sibling non-luxury brands Honda/Toyota?
How in the world do I place line of text EVENLY between two horizontal tikz lines?
How do LIGO and VIRGO know that a gravitational wave has its origin in a neutron star or a black hole?
Is it normal for gliders not to have attitude indicators?
Why doesn't ever smooth vector bundle admits a line bundle?
Why did the Apollo 13 crew extend the LM landing gear?
Kanji etymology of 毎?
Adding command shortcuts to /bin
Why do people keep telling me that I am a bad photographer?
Feasibility of lava beings?
Selecting elements from a list where the order is set by another list
Where are the "shires" in the UK?
Install LibreOffice-Writer Only not LibreOffice whole package
Why didn't this character get a funeral at the end of Avengers: Endgame?
Can you use "едать" and "игрывать" in the present and future tenses?
How can I get people to remember my character's gender?
Why did WWI include Japan?
To kill a cuckoo
How can Internet speed be 10 times slower without a router than when using the same connection with a router?
Has a commercial or military jet bi-plane ever been manufactured?
All of my Firefox add-ons been disabled suddenly, how can I re-enable them?
How to pass hash as password to ssh server
Why is "breaking the mould" positively connoted?
SOQL query WHERE filter by specific months
In Stroustrup's example, what does this colon mean in `return 1 : 2`? It's not a label or ternary operator
What does the explicit keyword mean?What does “static” mean in C?What does map(&:name) mean in Ruby?What does the question mark and the colon (?: ternary operator) mean in objective-c?What does the star operator mean?What does int argc, char *argv[] mean?What is the meaning of prepended double colon “::”?What does “dereferencing” a pointer mean?What does T&& (double ampersand) mean in C++11?C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I don't understand one particular use of a colon.
I found it in the book "The C++ programming language" by Bjarne Stroustrup, 4th edition, section 11.4.4, page 297:
void g(double y)
[&] f(y); // return type is void
auto z1 = [=](int x) return x+y; // return type is double
auto z2 = [=,y] if (y) return 1; else return 2; // error : body too complicated
// for return type deduction
auto z3 =[y]() return 1 : 2; // (Me: HERE!!!) return type is int
auto z4 = [=,y]()−>int if (y) return 1; else return 2; // OK: explicit return type
All comments from Stroustrup, except the one inside the parentheses.
I have no idea what it could be.
It seems like a conditional ternary operator without the first member (and without the "?"), but in that case I don't understand how it could work without a condition.
c++ syntax
|
show 2 more comments
I don't understand one particular use of a colon.
I found it in the book "The C++ programming language" by Bjarne Stroustrup, 4th edition, section 11.4.4, page 297:
void g(double y)
[&] f(y); // return type is void
auto z1 = [=](int x) return x+y; // return type is double
auto z2 = [=,y] if (y) return 1; else return 2; // error : body too complicated
// for return type deduction
auto z3 =[y]() return 1 : 2; // (Me: HERE!!!) return type is int
auto z4 = [=,y]()−>int if (y) return 1; else return 2; // OK: explicit return type
All comments from Stroustrup, except the one inside the parentheses.
I have no idea what it could be.
It seems like a conditional ternary operator without the first member (and without the "?"), but in that case I don't understand how it could work without a condition.
c++ syntax
6
It's a compile error on my end (gcc and clang). Plus all those lines need semicolons, but still an error.
– Cruz Jean
Apr 30 at 22:19
184
Moderator Note: Please think very carefully before casting a vote to close this as a "typo" question. Yes, the problem is a typo, but it's not a typo that the asker made. Rather, it is one found in a published book. That means this question and its answers may well be useful to others in the future, which is a strong counter-indicator for closing it as a typo. (UPDATE: This topic is now being discussed on Meta; please feel free to weigh in there.)
– Cody Gray♦
May 1 at 1:11
3
Perhaps the best answer would be: Try to compile the code; if it doesn't compile, that's a good indication that it's a typo.
– John Wiersba
yesterday
I can think of a number of examples off the top of my head that fail to compile (or even cause an internal compiler error) on one compiler, but are accepted without issue on a different one
– J. Antonio Perez
yesterday
1
@John I just tried some fold expressions with MSVC and they didn't compile. So clearly the whole chapter I just read must be a typo? ;) C++ compilers fail to compile valid C++ code all the time, comes from the language being absurdly complicated.
– Voo
23 hours ago
|
show 2 more comments
I don't understand one particular use of a colon.
I found it in the book "The C++ programming language" by Bjarne Stroustrup, 4th edition, section 11.4.4, page 297:
void g(double y)
[&] f(y); // return type is void
auto z1 = [=](int x) return x+y; // return type is double
auto z2 = [=,y] if (y) return 1; else return 2; // error : body too complicated
// for return type deduction
auto z3 =[y]() return 1 : 2; // (Me: HERE!!!) return type is int
auto z4 = [=,y]()−>int if (y) return 1; else return 2; // OK: explicit return type
All comments from Stroustrup, except the one inside the parentheses.
I have no idea what it could be.
It seems like a conditional ternary operator without the first member (and without the "?"), but in that case I don't understand how it could work without a condition.
c++ syntax
I don't understand one particular use of a colon.
I found it in the book "The C++ programming language" by Bjarne Stroustrup, 4th edition, section 11.4.4, page 297:
void g(double y)
[&] f(y); // return type is void
auto z1 = [=](int x) return x+y; // return type is double
auto z2 = [=,y] if (y) return 1; else return 2; // error : body too complicated
// for return type deduction
auto z3 =[y]() return 1 : 2; // (Me: HERE!!!) return type is int
auto z4 = [=,y]()−>int if (y) return 1; else return 2; // OK: explicit return type
All comments from Stroustrup, except the one inside the parentheses.
I have no idea what it could be.
It seems like a conditional ternary operator without the first member (and without the "?"), but in that case I don't understand how it could work without a condition.
c++ syntax
c++ syntax
edited yesterday
ᆼᆺᆼ
9,00243564
9,00243564
asked Apr 30 at 22:16
PiockñecPiockñec
666157
666157
6
It's a compile error on my end (gcc and clang). Plus all those lines need semicolons, but still an error.
– Cruz Jean
Apr 30 at 22:19
184
Moderator Note: Please think very carefully before casting a vote to close this as a "typo" question. Yes, the problem is a typo, but it's not a typo that the asker made. Rather, it is one found in a published book. That means this question and its answers may well be useful to others in the future, which is a strong counter-indicator for closing it as a typo. (UPDATE: This topic is now being discussed on Meta; please feel free to weigh in there.)
– Cody Gray♦
May 1 at 1:11
3
Perhaps the best answer would be: Try to compile the code; if it doesn't compile, that's a good indication that it's a typo.
– John Wiersba
yesterday
I can think of a number of examples off the top of my head that fail to compile (or even cause an internal compiler error) on one compiler, but are accepted without issue on a different one
– J. Antonio Perez
yesterday
1
@John I just tried some fold expressions with MSVC and they didn't compile. So clearly the whole chapter I just read must be a typo? ;) C++ compilers fail to compile valid C++ code all the time, comes from the language being absurdly complicated.
– Voo
23 hours ago
|
show 2 more comments
6
It's a compile error on my end (gcc and clang). Plus all those lines need semicolons, but still an error.
– Cruz Jean
Apr 30 at 22:19
184
Moderator Note: Please think very carefully before casting a vote to close this as a "typo" question. Yes, the problem is a typo, but it's not a typo that the asker made. Rather, it is one found in a published book. That means this question and its answers may well be useful to others in the future, which is a strong counter-indicator for closing it as a typo. (UPDATE: This topic is now being discussed on Meta; please feel free to weigh in there.)
– Cody Gray♦
May 1 at 1:11
3
Perhaps the best answer would be: Try to compile the code; if it doesn't compile, that's a good indication that it's a typo.
– John Wiersba
yesterday
I can think of a number of examples off the top of my head that fail to compile (or even cause an internal compiler error) on one compiler, but are accepted without issue on a different one
– J. Antonio Perez
yesterday
1
@John I just tried some fold expressions with MSVC and they didn't compile. So clearly the whole chapter I just read must be a typo? ;) C++ compilers fail to compile valid C++ code all the time, comes from the language being absurdly complicated.
– Voo
23 hours ago
6
6
It's a compile error on my end (gcc and clang). Plus all those lines need semicolons, but still an error.
– Cruz Jean
Apr 30 at 22:19
It's a compile error on my end (gcc and clang). Plus all those lines need semicolons, but still an error.
– Cruz Jean
Apr 30 at 22:19
184
184
Moderator Note: Please think very carefully before casting a vote to close this as a "typo" question. Yes, the problem is a typo, but it's not a typo that the asker made. Rather, it is one found in a published book. That means this question and its answers may well be useful to others in the future, which is a strong counter-indicator for closing it as a typo. (UPDATE: This topic is now being discussed on Meta; please feel free to weigh in there.)
– Cody Gray♦
May 1 at 1:11
Moderator Note: Please think very carefully before casting a vote to close this as a "typo" question. Yes, the problem is a typo, but it's not a typo that the asker made. Rather, it is one found in a published book. That means this question and its answers may well be useful to others in the future, which is a strong counter-indicator for closing it as a typo. (UPDATE: This topic is now being discussed on Meta; please feel free to weigh in there.)
– Cody Gray♦
May 1 at 1:11
3
3
Perhaps the best answer would be: Try to compile the code; if it doesn't compile, that's a good indication that it's a typo.
– John Wiersba
yesterday
Perhaps the best answer would be: Try to compile the code; if it doesn't compile, that's a good indication that it's a typo.
– John Wiersba
yesterday
I can think of a number of examples off the top of my head that fail to compile (or even cause an internal compiler error) on one compiler, but are accepted without issue on a different one
– J. Antonio Perez
yesterday
I can think of a number of examples off the top of my head that fail to compile (or even cause an internal compiler error) on one compiler, but are accepted without issue on a different one
– J. Antonio Perez
yesterday
1
1
@John I just tried some fold expressions with MSVC and they didn't compile. So clearly the whole chapter I just read must be a typo? ;) C++ compilers fail to compile valid C++ code all the time, comes from the language being absurdly complicated.
– Voo
23 hours ago
@John I just tried some fold expressions with MSVC and they didn't compile. So clearly the whole chapter I just read must be a typo? ;) C++ compilers fail to compile valid C++ code all the time, comes from the language being absurdly complicated.
– Voo
23 hours ago
|
show 2 more comments
3 Answers
3
active
oldest
votes
It's a typo. Look at Errata for 2nd and 3rd printings of The C++ Programming Language. The example must be like below:
auto z3 =[y]() return (y) ? 1 : 2;
9
Why(y)
and not justy
?
– Little Helper
2 days ago
4
@LittleHelper Perhaps its a best practice or something, I always see it written like that. Maybe to avoid confusion with more complicated comparisons...
– Redwolf Programs
2 days ago
22
Personally, I often use(cond) ? a : b
for clarity -- it helps me avoid misreading e.g. the statementfoo = x > y ? a : b
asfoo = x ...
when skimming through code.
– grawity
2 days ago
5
@LittleHelper It's not really needed there. However in a function-like macro it's best practise to put parentheses round the arguments where they are used, because otherwise expansion of the arguments can give unexpected behaviour. Consider a function-like macro to double a value "foo(x) x * 2" where you call it with "foo(2+3)". The result will be 2+(3*2) because the argument gets expanded as-is and precedence rules take over. If your macro is "foo(x) (x)*2" then you will correctly get (2+3)*2. It may be that Stroustrup has a habit of using that style everywhere for coding safety.
– Graham
yesterday
2
@Graham Very unlikely. Stroustrup essentially doesn't write function macros (C++ inline functions are better). Much more likely is that the ternary operator has somewhat complicated precedence rules, so it is good to habitually clarify the precedence with parens.
– Martin Bonner
22 hours ago
add a comment |
Looks to me like a simple typo. Should probably be:
auto z3 =[y]() return y ? 1 : 2;
Note that since the lambda doesn't take any parameters, the parens are optional. You could use this instead, if you preferred:
auto z3 =[y] return y ? 1 : 2;
add a comment |
return 1 : 2;
is a syntax error, it is not valid code.
A correct statement would be more like return (y) ? 1 : 2;
instead.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55929336%2fin-stroustrups-example-what-does-this-colon-mean-in-return-1-2-its-not-a%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
It's a typo. Look at Errata for 2nd and 3rd printings of The C++ Programming Language. The example must be like below:
auto z3 =[y]() return (y) ? 1 : 2;
9
Why(y)
and not justy
?
– Little Helper
2 days ago
4
@LittleHelper Perhaps its a best practice or something, I always see it written like that. Maybe to avoid confusion with more complicated comparisons...
– Redwolf Programs
2 days ago
22
Personally, I often use(cond) ? a : b
for clarity -- it helps me avoid misreading e.g. the statementfoo = x > y ? a : b
asfoo = x ...
when skimming through code.
– grawity
2 days ago
5
@LittleHelper It's not really needed there. However in a function-like macro it's best practise to put parentheses round the arguments where they are used, because otherwise expansion of the arguments can give unexpected behaviour. Consider a function-like macro to double a value "foo(x) x * 2" where you call it with "foo(2+3)". The result will be 2+(3*2) because the argument gets expanded as-is and precedence rules take over. If your macro is "foo(x) (x)*2" then you will correctly get (2+3)*2. It may be that Stroustrup has a habit of using that style everywhere for coding safety.
– Graham
yesterday
2
@Graham Very unlikely. Stroustrup essentially doesn't write function macros (C++ inline functions are better). Much more likely is that the ternary operator has somewhat complicated precedence rules, so it is good to habitually clarify the precedence with parens.
– Martin Bonner
22 hours ago
add a comment |
It's a typo. Look at Errata for 2nd and 3rd printings of The C++ Programming Language. The example must be like below:
auto z3 =[y]() return (y) ? 1 : 2;
9
Why(y)
and not justy
?
– Little Helper
2 days ago
4
@LittleHelper Perhaps its a best practice or something, I always see it written like that. Maybe to avoid confusion with more complicated comparisons...
– Redwolf Programs
2 days ago
22
Personally, I often use(cond) ? a : b
for clarity -- it helps me avoid misreading e.g. the statementfoo = x > y ? a : b
asfoo = x ...
when skimming through code.
– grawity
2 days ago
5
@LittleHelper It's not really needed there. However in a function-like macro it's best practise to put parentheses round the arguments where they are used, because otherwise expansion of the arguments can give unexpected behaviour. Consider a function-like macro to double a value "foo(x) x * 2" where you call it with "foo(2+3)". The result will be 2+(3*2) because the argument gets expanded as-is and precedence rules take over. If your macro is "foo(x) (x)*2" then you will correctly get (2+3)*2. It may be that Stroustrup has a habit of using that style everywhere for coding safety.
– Graham
yesterday
2
@Graham Very unlikely. Stroustrup essentially doesn't write function macros (C++ inline functions are better). Much more likely is that the ternary operator has somewhat complicated precedence rules, so it is good to habitually clarify the precedence with parens.
– Martin Bonner
22 hours ago
add a comment |
It's a typo. Look at Errata for 2nd and 3rd printings of The C++ Programming Language. The example must be like below:
auto z3 =[y]() return (y) ? 1 : 2;
It's a typo. Look at Errata for 2nd and 3rd printings of The C++ Programming Language. The example must be like below:
auto z3 =[y]() return (y) ? 1 : 2;
edited Apr 30 at 22:48
answered Apr 30 at 22:21
S.M.S.M.
7,11752231
7,11752231
9
Why(y)
and not justy
?
– Little Helper
2 days ago
4
@LittleHelper Perhaps its a best practice or something, I always see it written like that. Maybe to avoid confusion with more complicated comparisons...
– Redwolf Programs
2 days ago
22
Personally, I often use(cond) ? a : b
for clarity -- it helps me avoid misreading e.g. the statementfoo = x > y ? a : b
asfoo = x ...
when skimming through code.
– grawity
2 days ago
5
@LittleHelper It's not really needed there. However in a function-like macro it's best practise to put parentheses round the arguments where they are used, because otherwise expansion of the arguments can give unexpected behaviour. Consider a function-like macro to double a value "foo(x) x * 2" where you call it with "foo(2+3)". The result will be 2+(3*2) because the argument gets expanded as-is and precedence rules take over. If your macro is "foo(x) (x)*2" then you will correctly get (2+3)*2. It may be that Stroustrup has a habit of using that style everywhere for coding safety.
– Graham
yesterday
2
@Graham Very unlikely. Stroustrup essentially doesn't write function macros (C++ inline functions are better). Much more likely is that the ternary operator has somewhat complicated precedence rules, so it is good to habitually clarify the precedence with parens.
– Martin Bonner
22 hours ago
add a comment |
9
Why(y)
and not justy
?
– Little Helper
2 days ago
4
@LittleHelper Perhaps its a best practice or something, I always see it written like that. Maybe to avoid confusion with more complicated comparisons...
– Redwolf Programs
2 days ago
22
Personally, I often use(cond) ? a : b
for clarity -- it helps me avoid misreading e.g. the statementfoo = x > y ? a : b
asfoo = x ...
when skimming through code.
– grawity
2 days ago
5
@LittleHelper It's not really needed there. However in a function-like macro it's best practise to put parentheses round the arguments where they are used, because otherwise expansion of the arguments can give unexpected behaviour. Consider a function-like macro to double a value "foo(x) x * 2" where you call it with "foo(2+3)". The result will be 2+(3*2) because the argument gets expanded as-is and precedence rules take over. If your macro is "foo(x) (x)*2" then you will correctly get (2+3)*2. It may be that Stroustrup has a habit of using that style everywhere for coding safety.
– Graham
yesterday
2
@Graham Very unlikely. Stroustrup essentially doesn't write function macros (C++ inline functions are better). Much more likely is that the ternary operator has somewhat complicated precedence rules, so it is good to habitually clarify the precedence with parens.
– Martin Bonner
22 hours ago
9
9
Why
(y)
and not just y
?– Little Helper
2 days ago
Why
(y)
and not just y
?– Little Helper
2 days ago
4
4
@LittleHelper Perhaps its a best practice or something, I always see it written like that. Maybe to avoid confusion with more complicated comparisons...
– Redwolf Programs
2 days ago
@LittleHelper Perhaps its a best practice or something, I always see it written like that. Maybe to avoid confusion with more complicated comparisons...
– Redwolf Programs
2 days ago
22
22
Personally, I often use
(cond) ? a : b
for clarity -- it helps me avoid misreading e.g. the statement foo = x > y ? a : b
as foo = x ...
when skimming through code.– grawity
2 days ago
Personally, I often use
(cond) ? a : b
for clarity -- it helps me avoid misreading e.g. the statement foo = x > y ? a : b
as foo = x ...
when skimming through code.– grawity
2 days ago
5
5
@LittleHelper It's not really needed there. However in a function-like macro it's best practise to put parentheses round the arguments where they are used, because otherwise expansion of the arguments can give unexpected behaviour. Consider a function-like macro to double a value "foo(x) x * 2" where you call it with "foo(2+3)". The result will be 2+(3*2) because the argument gets expanded as-is and precedence rules take over. If your macro is "foo(x) (x)*2" then you will correctly get (2+3)*2. It may be that Stroustrup has a habit of using that style everywhere for coding safety.
– Graham
yesterday
@LittleHelper It's not really needed there. However in a function-like macro it's best practise to put parentheses round the arguments where they are used, because otherwise expansion of the arguments can give unexpected behaviour. Consider a function-like macro to double a value "foo(x) x * 2" where you call it with "foo(2+3)". The result will be 2+(3*2) because the argument gets expanded as-is and precedence rules take over. If your macro is "foo(x) (x)*2" then you will correctly get (2+3)*2. It may be that Stroustrup has a habit of using that style everywhere for coding safety.
– Graham
yesterday
2
2
@Graham Very unlikely. Stroustrup essentially doesn't write function macros (C++ inline functions are better). Much more likely is that the ternary operator has somewhat complicated precedence rules, so it is good to habitually clarify the precedence with parens.
– Martin Bonner
22 hours ago
@Graham Very unlikely. Stroustrup essentially doesn't write function macros (C++ inline functions are better). Much more likely is that the ternary operator has somewhat complicated precedence rules, so it is good to habitually clarify the precedence with parens.
– Martin Bonner
22 hours ago
add a comment |
Looks to me like a simple typo. Should probably be:
auto z3 =[y]() return y ? 1 : 2;
Note that since the lambda doesn't take any parameters, the parens are optional. You could use this instead, if you preferred:
auto z3 =[y] return y ? 1 : 2;
add a comment |
Looks to me like a simple typo. Should probably be:
auto z3 =[y]() return y ? 1 : 2;
Note that since the lambda doesn't take any parameters, the parens are optional. You could use this instead, if you preferred:
auto z3 =[y] return y ? 1 : 2;
add a comment |
Looks to me like a simple typo. Should probably be:
auto z3 =[y]() return y ? 1 : 2;
Note that since the lambda doesn't take any parameters, the parens are optional. You could use this instead, if you preferred:
auto z3 =[y] return y ? 1 : 2;
Looks to me like a simple typo. Should probably be:
auto z3 =[y]() return y ? 1 : 2;
Note that since the lambda doesn't take any parameters, the parens are optional. You could use this instead, if you preferred:
auto z3 =[y] return y ? 1 : 2;
answered Apr 30 at 22:21
Jerry CoffinJerry Coffin
391k52477925
391k52477925
add a comment |
add a comment |
return 1 : 2;
is a syntax error, it is not valid code.
A correct statement would be more like return (y) ? 1 : 2;
instead.
add a comment |
return 1 : 2;
is a syntax error, it is not valid code.
A correct statement would be more like return (y) ? 1 : 2;
instead.
add a comment |
return 1 : 2;
is a syntax error, it is not valid code.
A correct statement would be more like return (y) ? 1 : 2;
instead.
return 1 : 2;
is a syntax error, it is not valid code.
A correct statement would be more like return (y) ? 1 : 2;
instead.
answered Apr 30 at 22:21
Remy LebeauRemy Lebeau
347k19273469
347k19273469
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55929336%2fin-stroustrups-example-what-does-this-colon-mean-in-return-1-2-its-not-a%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
6
It's a compile error on my end (gcc and clang). Plus all those lines need semicolons, but still an error.
– Cruz Jean
Apr 30 at 22:19
184
Moderator Note: Please think very carefully before casting a vote to close this as a "typo" question. Yes, the problem is a typo, but it's not a typo that the asker made. Rather, it is one found in a published book. That means this question and its answers may well be useful to others in the future, which is a strong counter-indicator for closing it as a typo. (UPDATE: This topic is now being discussed on Meta; please feel free to weigh in there.)
– Cody Gray♦
May 1 at 1:11
3
Perhaps the best answer would be: Try to compile the code; if it doesn't compile, that's a good indication that it's a typo.
– John Wiersba
yesterday
I can think of a number of examples off the top of my head that fail to compile (or even cause an internal compiler error) on one compiler, but are accepted without issue on a different one
– J. Antonio Perez
yesterday
1
@John I just tried some fold expressions with MSVC and they didn't compile. So clearly the whole chapter I just read must be a typo? ;) C++ compilers fail to compile valid C++ code all the time, comes from the language being absurdly complicated.
– Voo
23 hours ago