do some whitespace janitor work

master
neingeist 10 years ago
parent 0e43b30736
commit 7db74eb991

@ -3,11 +3,9 @@
class mybase { class mybase {
protected: protected:
std::string ids; std::string ids;
public: public:
mybase(std::string ids) mybase(std::string ids)
: ids(ids) {} : ids(ids) {}
@ -17,16 +15,13 @@ class mybase {
}; };
class myclass : public mybase { class myclass : public mybase {
public: public:
myclass(std::string ids) myclass(std::string ids)
: mybase(ids) {} : mybase(ids) {}
void foo() { void foo() {
std::cout << "i'm a myclass! ids: " << ids << std::endl; std::cout << "i'm a myclass! ids: " << ids << std::endl;
} }
}; };
void nocast(myclass* x) { void nocast(myclass* x) {
@ -40,8 +35,8 @@ void ccast(void* x) {
} }
void staticcast(void* x) { void staticcast(void* x) {
// C++ static_cast. When I *know* it's myclass*, and want to revert an implicit // C++ static_cast. When I *know* it's myclass*, and want to revert an
// conversion. // implicit conversion.
myclass* foo = static_cast<myclass*>(x); myclass* foo = static_cast<myclass*>(x);
foo->foo(); foo->foo();
} }

@ -35,7 +35,8 @@ void implicitly_waiting() {
long int p2 = 685102597328182763; long int p2 = 685102597328182763;
std::future<bool> fut = std::async(std::launch::async, is_prime, p2); std::future<bool> fut = std::async(std::launch::async, is_prime, p2);
std::cout << "just getting the result, doing an implicit wait():" << std::endl; std::cout << "just getting the result, doing an implicit wait():";
std::cout << std::endl;
bool x = fut.get(); bool x = fut.get();
std::cout << p2 << " " << (x?"is":"is not") << " prime." << std::endl; std::cout << p2 << " " << (x?"is":"is not") << " prime." << std::endl;
} }

@ -7,7 +7,6 @@
using namespace std; using namespace std;
int main() { int main() {
// notice how the lists are nested to match the templates' parameters: // notice how the lists are nested to match the templates' parameters:
map<string, vector<pair<string, int>>> name_languages_year { map<string, vector<pair<string, int>>> name_languages_year {
{"Dennis Ritchie", {{"B", 1969}, {"C", 1973}}}, {"Dennis Ritchie", {{"B", 1969}, {"C", 1973}}},
@ -27,5 +26,4 @@ int main() {
// prints 'Lisp': // prints 'Lisp':
cout << name_languages_year["John McCarthy"].at(0).first << endl; cout << name_languages_year["John McCarthy"].at(0).first << endl;
} }

@ -1,4 +1,4 @@
/* http://en.wikipedia.org/wiki/C++14 */ // http://en.wikipedia.org/wiki/C++14
#include <cassert> #include <cassert>
#include <iostream> #include <iostream>

@ -32,7 +32,8 @@ class Hammer : public Tool {
} }
void use(Nail nail) { void use(Nail nail) {
std::cout << "The nail is " << nail.getLength() << " cm long" << std::endl; std::cout << "The nail is " << nail.getLength() << " cm long"
<< std::endl;
} }
}; };

@ -1,8 +1,7 @@
#include <cassert> #include <cassert>
#include <iostream> #include <iostream>
int main() int main() {
{
int someInteger = 256; int someInteger = 256;
short someShort; short someShort;
long someLong; long someLong;

Loading…
Cancel
Save