diff --git a/Lightning Talks/Anatomy of a Smart Pointer/Anatomy of a Smart Pointer - Michael VanLoon.pptx b/Lightning Talks/Anatomy of a Smart Pointer/Anatomy of a Smart Pointer - Michael VanLoon.pptx new file mode 100644 index 0000000..6e76a35 Binary files /dev/null and b/Lightning Talks/Anatomy of a Smart Pointer/Anatomy of a Smart Pointer - Michael VanLoon.pptx differ diff --git a/Lightning Talks/Assertions of Competence/Assertions of Competence - Michael VanLoon.pptx b/Lightning Talks/Assertions of Competence/Assertions of Competence - Michael VanLoon.pptx new file mode 100644 index 0000000..686eec6 Binary files /dev/null and b/Lightning Talks/Assertions of Competence/Assertions of Competence - Michael VanLoon.pptx differ diff --git a/Lightning Talks/C++ Conferences/C++ Conferences - Jens Weller.pdf b/Lightning Talks/C++ Conferences/C++ Conferences - Jens Weller.pdf new file mode 100644 index 0000000..e2cbf84 Binary files /dev/null and b/Lightning Talks/C++ Conferences/C++ Conferences - Jens Weller.pdf differ diff --git a/Lightning Talks/C++ Hardware Register Access/C++ Hardware Register Access - Ken Smith.pdf b/Lightning Talks/C++ Hardware Register Access/C++ Hardware Register Access - Ken Smith.pdf new file mode 100644 index 0000000..445b7a7 Binary files /dev/null and b/Lightning Talks/C++ Hardware Register Access/C++ Hardware Register Access - Ken Smith.pdf differ diff --git a/Lightning Talks/C++ Package Manager/C++ Package Manager - Boris Kolpackov.pdf b/Lightning Talks/C++ Package Manager/C++ Package Manager - Boris Kolpackov.pdf new file mode 100644 index 0000000..d67950b Binary files /dev/null and b/Lightning Talks/C++ Package Manager/C++ Package Manager - Boris Kolpackov.pdf differ diff --git a/Lightning Talks/C++ Puzzlers/01_using-solution.cpp b/Lightning Talks/C++ Puzzlers/01_using-solution.cpp new file mode 100644 index 0000000..08ed2e3 --- /dev/null +++ b/Lightning Talks/C++ Puzzlers/01_using-solution.cpp @@ -0,0 +1,25 @@ +#include + +int main() // Part I: Legal, or compile error? +{ // LEGAL! + using namespace std; + + cout << "hello, cruel world!" << endl; // usual "cout" + + int cout; // this cout HIDES the one at namespace scope + cout = 10; // uses the int + std::cout << "cout = " << cout << endl; // 2nd cout is the int + std::cout << "cout << 5 = " << (cout << 5) << endl; // 2nd cout is int +} + + +// Part II: What if we replaced +// using namespace std; +// with: +// using std::cout; +// using std::endl; +// +// ? + +// Answer: ILLEGAL! A using DECLARATION brings the name into THIS scope, +// so you can't have a redeclaration in the same scope. diff --git a/Lightning Talks/C++ Puzzlers/01_using.cpp b/Lightning Talks/C++ Puzzlers/01_using.cpp new file mode 100644 index 0000000..ddbe6ad --- /dev/null +++ b/Lightning Talks/C++ Puzzlers/01_using.cpp @@ -0,0 +1,24 @@ +// NOTE: There are TWO PARTS to this puzzler! + +#include + +int main() // Part I: Legal, or compile error? +{ + using namespace std; + + cout << "Hello, puzzling world!" << endl; + + int cout; + cout = 10; + std::cout << "cout = " << cout << endl; + std::cout << "cout << 5 = " << (cout << 5) << endl; +} + + +// Part II: What if we replaced +// using namespace std; +// with: +// using std::cout; +// using std::endl; +// +// ? diff --git a/Lightning Talks/C++ Puzzlers/02_oops-solution.cpp b/Lightning Talks/C++ Puzzlers/02_oops-solution.cpp new file mode 100644 index 0000000..ac8236e --- /dev/null +++ b/Lightning Talks/C++ Puzzlers/02_oops-solution.cpp @@ -0,0 +1,33 @@ +// +// Morning puzzler: see last comment (please don't reveal answer +// until everyone has had a chance to think about it...) + +#include +using namespace std; + +class Base +{ + public: + Base() {} + virtual void func() + { + cout << "Base's func() now running\n"; + } +}; + +class Derived : public Base +{ + public: + Derived() {} + void func() + { + Base:func(); // this is a LABEL! + cout << "Derived's func() now running\n"; + } +}; + +int main() +{ + Base *bp = new Derived; + bp->func(); // What's the run-time result? +} // Result is infinite recursion and crash. diff --git a/Lightning Talks/C++ Puzzlers/02_oops.cpp b/Lightning Talks/C++ Puzzlers/02_oops.cpp new file mode 100644 index 0000000..2d107e6 --- /dev/null +++ b/Lightning Talks/C++ Puzzlers/02_oops.cpp @@ -0,0 +1,30 @@ +// Puzzler: see comment at bottom for the question +// (PLEASE don't say anything about the REASON, just answer the question!) + +#include +using namespace std; + +class Base +{ + public: + virtual void func() + { + cout << "Base's func() now running\n"; + } +}; + +class Derived : public Base +{ + public: + void func() + { + Base:func(); + cout << "Derived's func() now running\n"; + } +}; + +int main() +{ + Base *bp = new Derived; + bp->func(); // Question: What's the runtime behavior? +} diff --git a/Lightning Talks/C++ Puzzlers/03_inline-solution.h b/Lightning Talks/C++ Puzzlers/03_inline-solution.h new file mode 100644 index 0000000..8f2a3b3 --- /dev/null +++ b/Lightning Talks/C++ Puzzlers/03_inline-solution.h @@ -0,0 +1,28 @@ +// T.h: +// Which do think is best? +// +// ANSWER: I personally prefer option #3, because the INTERFACE +// should not traffic in IMPLEMENTATION DETAILS...and whether +// any particular function is inline or not is NOT part of +// the interface a client has any need to know or care about. + +#include +using std::cout; + +class T +{ +public: + void foo() + { + cout << "foo()\n"; // option #1: "in-situ" + } + + inline void bar(); // option #2 + + void zot(); // option #3 +}; + +void T::bar() { cout << "bar()\n"; } // option #2 + +inline void T::zot() { + cout << "zot()\n"; } // option #3 diff --git a/Lightning Talks/C++ Puzzlers/03_inline.h b/Lightning Talks/C++ Puzzlers/03_inline.h new file mode 100644 index 0000000..b7b7b99 --- /dev/null +++ b/Lightning Talks/C++ Puzzlers/03_inline.h @@ -0,0 +1,29 @@ +// Not a "puzzler" in the usual sense, but worth thinking about: +// Inline member functions should always be defined in +// header files...but there are 3 totally equivalent (and legal) +// ways to do this, syntactically. +// +// Are there any reasons to prefer one style above another? +// (THERE IS NO DIFFERENCE in semantics or performance!) +// + +#include // Note: This is ALL in a header file +using std::cout; + +class T +{ +public: + void foo() + { + cout << "foo()\n"; // option #1: "in-situ" (complete) + } + + inline void bar(); // option #2 (declaration) + + void zot(); // option #3 (declaration) +}; + +void T::bar() { cout << "bar()\n"; } // option #2 (definition) + +inline void T::zot() { + cout << "zot()\n"; } // option #3 (definition) diff --git a/Lightning Talks/C++ Puzzlers/04_hello-solution.cpp b/Lightning Talks/C++ Puzzlers/04_hello-solution.cpp new file mode 100644 index 0000000..22381fa --- /dev/null +++ b/Lightning Talks/C++ Puzzlers/04_hello-solution.cpp @@ -0,0 +1,18 @@ +// Display "hello, world" without using any semi-colons +// in your program + +#include + +int main() +{ + if (std::cout << "Hello, World") {} +} + + +// In C: + +int main() +{ + if (printf("Hello, world")) {} +} + diff --git a/Lightning Talks/C++ Puzzlers/04_hello.txt b/Lightning Talks/C++ Puzzlers/04_hello.txt new file mode 100644 index 0000000..6d89727 --- /dev/null +++ b/Lightning Talks/C++ Puzzlers/04_hello.txt @@ -0,0 +1,12 @@ +Puzzler: + +Write a portable C++ (and/or a C) program to display + + Hello, World + +on the standard output-- + + WITHOUT USING *ANY* SEMICOLONS IN YOUR CODE. + + (Do not worry about what's in Standard header files.) + diff --git a/Lightning Talks/C++ Puzzlers/05_thetype-solution.cpp b/Lightning Talks/C++ Puzzlers/05_thetype-solution.cpp new file mode 100644 index 0000000..3d566b2 --- /dev/null +++ b/Lightning Talks/C++ Puzzlers/05_thetype-solution.cpp @@ -0,0 +1,41 @@ +#include +using namespace std; + +class A +{ + public: + A (int i) {} +}; + +class B { + public: + B (A a) {} +}; + +int main() +{ + int i = 1; + B b(A(i)); // ******: declaration of function: B b(A); + + b(A(5)); // Call the function +} + +B b(A a) // And here's an implementation... +{ + cout << "b() called!\n"; + return B(a); +} + +// This analysis explains why the compiler sees that as a func. decl.: + +int f(int x); // a function taking an int +int f(int (x)); // redundant parentheses around parameter name OK; still + // a declaration of a function f, not an int initialized by + // static_cast(x) + + +B b(A i); // a function taking an A +B b(A (i)); // redundant parentheses around parameter name OK; still + // a declaration of a function b, not a B object initialized by + // an A constructed from i. + diff --git a/Lightning Talks/C++ Puzzlers/05_thetype.cpp b/Lightning Talks/C++ Puzzlers/05_thetype.cpp new file mode 100644 index 0000000..a0a842c --- /dev/null +++ b/Lightning Talks/C++ Puzzlers/05_thetype.cpp @@ -0,0 +1,24 @@ +// +// Puzzler +// + +#include +using namespace std; + +class A +{ + public: + A (int i) {} +}; + +class B { + public: + B (A a) {} +}; + +int main() +{ + int i = 1; + B b(A(i)); // what is b's type? +} + diff --git a/Lightning Talks/C++ Puzzlers/README.TXT b/Lightning Talks/C++ Puzzlers/README.TXT new file mode 100644 index 0000000..a82fbdc --- /dev/null +++ b/Lightning Talks/C++ Puzzlers/README.TXT @@ -0,0 +1,16 @@ +To all attendees of my 2014 15-minute "C++ Puzzlers" Lightgning Talk: + +Thanks so much for attending the Lightning Talk! + +I thought you might appreciate having the Puzzlers with my +little soltions attached, so I'm putting this together. + +I had up to 5 to present if time permitted, but it didn't (as +I pretty much expected). I'm adding them to the archive just +for the heck of it. + +Enjoy, + -leor + www.bdsoft.com + (On-Site C++ Training, really just in C++ these days) + diff --git a/Lightning Talks/Convergent Evolution/Convergent Evolution - Karl Niu.pdf b/Lightning Talks/Convergent Evolution/Convergent Evolution - Karl Niu.pdf new file mode 100644 index 0000000..4f96c60 Binary files /dev/null and b/Lightning Talks/Convergent Evolution/Convergent Evolution - Karl Niu.pdf differ diff --git a/Lightning Talks/Cross platform GUID association with types/Cross platform GUID association with types - Vladimir Morozov.pdf b/Lightning Talks/Cross platform GUID association with types/Cross platform GUID association with types - Vladimir Morozov.pdf new file mode 100644 index 0000000..faa996f Binary files /dev/null and b/Lightning Talks/Cross platform GUID association with types/Cross platform GUID association with types - Vladimir Morozov.pdf differ diff --git a/Lightning Talks/Four Year Bug/Four Year Bug - Kevin Carpenter.pdf b/Lightning Talks/Four Year Bug/Four Year Bug - Kevin Carpenter.pdf new file mode 100644 index 0000000..5e1886f Binary files /dev/null and b/Lightning Talks/Four Year Bug/Four Year Bug - Kevin Carpenter.pdf differ diff --git a/Lightning Talks/Return values take a closure walk/Return values take a closure walk - Martin Troxler.pdf b/Lightning Talks/Return values take a closure walk/Return values take a closure walk - Martin Troxler.pdf new file mode 100644 index 0000000..cc67bd6 Binary files /dev/null and b/Lightning Talks/Return values take a closure walk/Return values take a closure walk - Martin Troxler.pdf differ diff --git a/Lightning Talks/Rolling Your Own Circuit Simulator/Rolling Your Own Circuit Simulator - Jeff Trull.pdf b/Lightning Talks/Rolling Your Own Circuit Simulator/Rolling Your Own Circuit Simulator - Jeff Trull.pdf new file mode 100644 index 0000000..c67150c Binary files /dev/null and b/Lightning Talks/Rolling Your Own Circuit Simulator/Rolling Your Own Circuit Simulator - Jeff Trull.pdf differ diff --git a/Lightning Talks/Software Transactional Memory/Software Transactional Memory, For Reals - Brett Hall.pdf b/Lightning Talks/Software Transactional Memory/Software Transactional Memory, For Reals - Brett Hall.pdf new file mode 100644 index 0000000..5c42783 Binary files /dev/null and b/Lightning Talks/Software Transactional Memory/Software Transactional Memory, For Reals - Brett Hall.pdf differ diff --git a/Lightning Talks/Test Driven Performance/Test Driven Performance - Lenny Maiorani.pdf b/Lightning Talks/Test Driven Performance/Test Driven Performance - Lenny Maiorani.pdf new file mode 100644 index 0000000..ac31625 Binary files /dev/null and b/Lightning Talks/Test Driven Performance/Test Driven Performance - Lenny Maiorani.pdf differ diff --git a/Lightning Talks/The New Old Thing/The New Old Thing - Jonathan Caves.pdf b/Lightning Talks/The New Old Thing/The New Old Thing - Jonathan Caves.pdf new file mode 100644 index 0000000..f004b34 Binary files /dev/null and b/Lightning Talks/The New Old Thing/The New Old Thing - Jonathan Caves.pdf differ diff --git a/Lightning Talks/The New Old Thing/The New Old Thing - Jonathan Caves.pptx b/Lightning Talks/The New Old Thing/The New Old Thing - Jonathan Caves.pptx new file mode 100644 index 0000000..07e3884 Binary files /dev/null and b/Lightning Talks/The New Old Thing/The New Old Thing - Jonathan Caves.pptx differ diff --git a/Lightning Talks/The Perils of Strict Aliasing/The Perils of Strict Aliasing - Andy Webber.pdf b/Lightning Talks/The Perils of Strict Aliasing/The Perils of Strict Aliasing - Andy Webber.pdf new file mode 100644 index 0000000..88d522e Binary files /dev/null and b/Lightning Talks/The Perils of Strict Aliasing/The Perils of Strict Aliasing - Andy Webber.pdf differ diff --git a/Lightning Talks/Wishful Thinking/Wishful Thinking - Roland Bock.pdf b/Lightning Talks/Wishful Thinking/Wishful Thinking - Roland Bock.pdf new file mode 100644 index 0000000..616aa2f Binary files /dev/null and b/Lightning Talks/Wishful Thinking/Wishful Thinking - Roland Bock.pdf differ diff --git a/Lightning Talks/Writing a Python Interpreter/Writing a Python Interpreter for Fun and Profit - Shy Shalom.pdf b/Lightning Talks/Writing a Python Interpreter/Writing a Python Interpreter for Fun and Profit - Shy Shalom.pdf new file mode 100644 index 0000000..369c428 Binary files /dev/null and b/Lightning Talks/Writing a Python Interpreter/Writing a Python Interpreter for Fun and Profit - Shy Shalom.pdf differ