federico-busato / modern-cpp-programming Goto Github PK
View Code? Open in Web Editor NEWModern C++ Programming Course (C++03/11/14/17/20/23/26)
Home Page: https://federico-busato.github.io/Modern-CPP-Programming/
Modern C++ Programming Course (C++03/11/14/17/20/23/26)
Home Page: https://federico-busato.github.io/Modern-CPP-Programming/
In Chapter 2, slide 33, the link to the floating point book is stale. It should be http://www.cburch.com/books/float/index.html.
Modern-CPP-Programming/README.md
Line 61 in 9bc1c64
The link referenced uses an underscore, but the actual file seem to use a space.
01.Introduction.pdf; page 11.
'The lag of these things formed the reason...' should read 'The lack of these things formed the reason...'.
Hello Federico,
I have a doubt about page 10. This specific slide is explaining the difference between Implicit and Explicit Template Instantiation.
The last row is showing instruction template f<int>(int);
But the explicit template instantiation shouldn't be for instance f<int>(3);
?
Because the instruction template f<int>(int);
it seems a template specialization, something like:
template<>
void f<int>(int);
I apologize in advance if I misunderstood the meaning of the slide, but I am the perfect "dumb user" since I am learning C++ from your course without any previous experience 😄
Thanks,
Gianmario
On slide 31 of 22.Optimization_III.pdf
, the code for loop fission is the same as the code for Loop Fusion in the previous slide.
Hello,
A small typo that we can remove at page 41 where the semicolon after the braces is not needed.
Not sure if I am missing something, maybe we can also remove the comment near to function call g()
because here the copy constructor is not called.
Thanks.
It is understandable that 'using namespace std' is used for educational reasons, but then I think it should be pointed out somewhere in the text that it is done for that reason, but is currently considered bad practice in any style guide.
I think at page 38/81. There are some typos:
"deferencing"
should be "dereferencing"
.
In 02.Basic_Concepts_I.pdf
, on slide 94 inside the function areFloatNearlyEqual
there is the following code for catching Inf or NaN arguments:
if (std::isfinite(a) || isfinite(b)) // a = ±∞, b = ±∞ and NaN
return false;
But it was causing the function to return false
always, even for finite values. I think it should be:
if (!(std::isfinite(a) && std::isfinite(b))) // a = ±∞, b = ±∞ and NaN
return false;
Hello Federico,
I completed the lecture and I collected some observations.
Slide 31: just because I am a total newbie without almost any previous C++ experience, it was not immediate for me that decltype
is returning a type to be used in a subsequent declaration.
Therefore I was able to understand fully the example only when I tried to compile the following code. Please feel free to judge if in your opinion it is the case to update the slide or not.
decltype(x) d1;
decltype(2 + 3.0) d2;
decltype(y) d3 = x;
decltype(z) d4 = z;
decltype(array) d5;
decltype(f(1, 2.0f)) d6();
Slide 32:
I tried to compile the code and I got an error message -fpermissive
because of missing initialization for const A a;
therefore I changed it as const A a{};
Similarly as the previous slide. I was able to comprehend fully the meaning decltype
(it returns a type to be used in a subsequent declaration) only when I compiled the following code:
decltype(x) d1;
decltype((x)) d2 = x;
decltype(f) d3;
decltype((f)) g = f;
decltype(a.x) d4;
decltype((a.x)) d5 = x;
Slide 38: small typo it should be is_null_pointer
Slide 42: small typo missing semicolon ; at the end of the instruction / definitions.
it should be std::is_base_of_v
instead of std::is_base_v
Slide 44 small typo it should be remove_reference
Thanks
Gianmario
Hi Federico,
Just spotted another little typo. :-)
On Page 48/61 in in 07.Object_Oriented_II.pdf, you might want "y.Array" to be "y.array".
By the way, I really like your idea of making a copy and swapping it with the current object.
Thanks a bunch once again.
Wishing you a cozy weekend.
Kind regards,
Soohwan
On slide 20 in 14.Iterators_Containers_Alg.pdf
, you mention std::unsorted_set
, std::unsorted_map
, and std::unsorted_multiset
, which I believe should be std::unordered_set
, std::unordered_map
, and std::unordered_multiset
.
In 03 Basic Concepts: IEEE Floating-Point Standard, I found that there are some statements that describe the IEEE764 standard, but it should actually be IEEE754.
In 13.Code_Convention.pdf on page marked 60/80 (absolute page 71/95) it says "Use noexpect
instead" where it should say "Use noexcept
instead".
In chapter 2, on page 39, the second example reads:
i = 0;
i = i++ + 2; // until C++17: undefined behavior
// since C++17: i = 3
I believe i = 2
. GCC 11.4.0 seems to agree:
$ cat test.cpp
#include <iostream>
int main() {
int i = 0;
i = ++i + 2;
std::cout << i << "\n";
i = 0;
i = i++ + 2;
std::cout << i << "\n";
}
$ g++ -std=c++17 test.cpp
$ ./a.out
3
2
I got the same behavior with -std=c++20
and -std=c++23
.
Hi Federico,
Not sure if I have eaten too much, I have a couple of doubts at page 15:
print1
should be void
template<int A = 3, int B>
The comment // 'value' disapear
should be corrected to // 'value' disappears
.
Name hasnain Ahmed
New Web development
Plz come work with together
Hey, Sorry if this is not the right place to do this. But i am very curious about the the font you have used in the examples in the pdf.
Reference on Page 12 in Indtroduction.pdf.
In chapter 3 on page 12, "csoncepts" appears where I believe "concepts" was meant.
Dear Federico,
perhaps an error in 05.Basic_Concepts_IV.pdf
slide 33.
auto lambda3 = [this]() { return data; }; // copy by-reference, return 2
it returns 1, not 2.
For instance, the following prints 1 with -std=c++20
:
#include <iostream>
class A {
public:
int data = 1;
void f(){
int var = 2;
auto lambda3 = [this](){return data;};
std::cout<<lambda3()<<std::endl;
}
};
int main(){
A a;
a.f();
return 0;
}
The words should be "Table of Contents" not "Table of Context." You're literally presenting a table (i.e., listing) of the contents. This error seems to appear in all the chapters, unfortunately.
#include
using namespace std;
int main(){
cout >> " Hello World" >> endl;
return 0;
}
Hi Federico, I think there are some errors in the Iterators Containers slides.
std::array
):
#include <algorithm>
is missing; without it we cannot use std::sort
arr1
and arr2
need to be of the same size, otherwise operator>
won't work;
at the end of the last line of codestd::vector
):
vec5.fill(3)
does not work, since std::vector
does not have such a method. Instead, std::fill(vec5.begin(), vec5.end(), 3)
can be usedvec1
, the comment is 2, 3, 5
, but I believe it should be 2, 3, 4
std::list
):
list5.fill(3)
needs to be changed to std::fill(list5.begin(), list5.end(), 3)
list1.merge(arr5)
: I believe it should be list1.merge(list5)
merge()
does not work as expected, since both lists should be sorted. Moreover, I think the comments after that are not correct, as they use the result of the merge as a starting point (for example I got [2, 3, 2, 3, 3, 5]
instead of [2, 3, 2, 5, 3, 3]
)std::deque
):
queue5.fill(3)
to std::fill(queue5.begin(), queue5.end(), 3)
std::forward_list
):
flist5.fill(4)
to std::fill(flist5.begin(), flist5.end(), 4)
flist1.erase_after(flist1.begin(), 0)
does not compilemerge()
is called, both list should be sortedstd::multiset
):
#include <multiset>
should be changed to #include <set>
mset2
the comment says empty map
(it should say multiset
/set
)*(it + 1)
does not compile (maybe *(++it)
can be used?)
std::priority_queue
):
queue1.push(5); queue1.push(4);
; but probably it should be pqueue1.push(5); pqueue1.push(4);
I hope everything is clear and I didn't make any silly mistakes!
Hi Federico,
Hope I'm not bothering you.
I spotted what might be another typo on Page 33/61 in 07.Object_Oriented_II.pdf.
When you return the Point object from the operator+, it seems like you intended to return {x + p.x, y + p.y} instead of {x + p.x, y + p.x}.
Time is flying, and it's getting pretty chilly here in South Korea.
Wishing you a fantastic end to the year season.
Kind regards,
Soohwan
Hi Federico,
slide 15/33 of Basic Concepts III states that:
Contrary to C, C++ does not allow anonymous struct (i.e. without a name)
I think it would be useful to add a note saying that the C++ standard does not allow anonymous structs, but most compilers (gcc, clang, MSVC and others) support them.
Thank you for making the book public.
Could you provide an all-in-one.pdf ?
Hey federico,
Hope this finds you well! 👋 Your C++ course repo is a goldmine, seriously. 🚀 I'm in the process of putting together a university course on C++, and I'd love to use and tweak the material for my slides.
Your coverage of all the topics is spot-on, and I think it'll be a game-changer for my students.
I noticed there's no license file, so I wanted to check with you. I'll, of course, give full credit and add a link back to your repo.
If you're cool with it or have any conditions, just hit me up. Your work is top-notch, and I want to make sure I'm on the right side of things.
Cheers!
In chapter 3, page 50, this line appears:
op ∈ {+, −, *, \} denotes exact precision operations
Where \
appears, was /
intended? I think op is intended to be the set of basic mathematical operations: add, subtract, multiply, divide. In that case, I'd expected /
to be used for division instead \
.
In 17.Iterators_Containers_Alg.pdf
, there is an example of implementing an iterator class using std::iterator
. std::iterator
is deprecated in C++17 for various reasons.
https://stackoverflow.com/questions/43268146/why-is-stditerator-deprecated
Hi, could it be possible to generate an epub version of each pdf ()or combined) so they can be sent to ebook readers (like Kindle) and take advantages of the extra features of those over plain PDFs, like change font size, etc?
I know there are pdf to epub converters but they arent very good and it would be better to convert from whatever your original source material is.
Thanks.
Hello Federico,
In the document 02.Basic_Concepts_I.pdf, on slide 18/100, you have written that char
is a one's complement type with a range from -127 to 127, and I believe this is incorrect. The range could be either the same as signed char
or unsigned char
, depending on the platform. For example, the range with x86 processors is -128 to 127 (example here: https://godbolt.org/z/G9MYbhGfd). On ARM processors, it is from 0 to 255.
Best regards,
Marco
07.Object_Oriented_I.pdf::slide_7:
-The resource is automatically *releases* when the object gets out of scope (destructor)
+The resource is automatically *released* when the object gets out of scope (destructor)
Hi Federico,
Thanks you very much for sharing your slides.
I found some typos in 05.Basic_Concepts_IV.pdf.
Page 5
The comment "// linking error "f" ist not defined" in the last line should be "// linking error "g" is not defined"
Page 32
First, I think "std::is_is_arithmetic" should be "std::is_arithmetic". "is_is" must be a typo.
Second, I'm not an expert on the "requires" keyword, but should it be "std::is_arithmetic_v"?
Hope this helpful.
Thanks again.
Kind regards,
Soohwan
On page 54, "const Keywords and Pointers", the word "refereed" appears in each of the bullet points.
I believe it should be "referred"!
Hi Federico,
Hope you're doing well.
I think I found another typo. :-)
In the second option on Page 47/61 in 07.Object_Oriented_II.pdf,
I think "swap(this, x);" should be "swap(*this, x);".
The declaration in the next page says "void swap(A& x, A&y);"
and thus instead of passing the this pointer, I think we need to pass the object after dereferencing.
Hope this helpful for improving your work.
Thank you very much again.
Kind regards,
Soohwan
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.