gotw Questions

3

In Herb Sutter's When Is a Container Not a Container?, he shows an example of taking a pointer into a container: // Example 1: Is this code valid? safe? good? // vector<char> v; // ... ...
Marja asked 21/9, 2015 at 18:3

2

Solved

In GotW 94, Herb Sutter draws a distinction between the "classic C++" declaration const char* s = "Hello"; and the "modern" style auto s = "Hello"; He tells us that there's a "subtle differen...
Ferd asked 18/12, 2014 at 15:50

2

Solved

I was reading comments on Herb Sutter's Guru of the Week redux about virtual functions, and finally saw him mentioning this: [...] “uses of final are rarer” – well, they sort of are. I don’t kno...
Devoirs asked 29/5, 2013 at 7:44

3

Solved

Taken from: http://herbsutter.com/2013/05/22/gotw-5-solution-overriding-virtual-functions/ Why should we write: auto pb = unique_ptr<base>{ make_unique<derived>() }; Instead of just...
Zipnick asked 27/5, 2013 at 13:47

3

Solved

According to GOTW #56, there is a potential classic memory leak and exception safety issues in the following code: // In some header file: void f( T1*, T2* ); // In some implementation file: f( new...
Bisayas asked 16/5, 2013 at 19:10

2

Solved

Recently, I was reading the post: Double or Nothing from GOTW by Herb Sutter I am a little confused with the explanation of the following program: int main() { double x = 1e8; while( x > 0 )...
Masteratarms asked 16/5, 2013 at 14:51

2

Solved

Taken directly from http://herbsutter.com/2013/05/09/gotw-1-solution/ While widget w(); is clear for me, I have no idea how can the below code be a function declaration? // same problem (ga...
Lurdan asked 16/5, 2013 at 13:27

2

Solved

First read Herb's Sutters GotW posts concerning pimpl in C++11: GotW #100: Compilation Firewalls (Difficulty: 6/10) GotW #101: Compilation Firewalls, Part 2 (Difficulty: 8/10) I'm having some t...
Cruck asked 21/12, 2011 at 19:50

4

Solved

There is a example in http://www.gotw.ca/gotw/067.htm int main() { double x = 1e8; //float x = 1e8; while( x > 0 ) { --x; } } When you change the double to float, it's a infinite loop i...
Circumference asked 9/8, 2011 at 12:8
1

© 2022 - 2024 — McMap. All rights reserved.