Skip to content

Commit 3d2fd94

Browse files
committed
header: make comments beautiful
1 parent 1c702c9 commit 3d2fd94

1 file changed

Lines changed: 42 additions & 43 deletions

File tree

‎cpp/common.hpp‎

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
/*
2-
# Headers
3-
4-
C++ stdlib headers that are not C stdlib headers don't have the `.h` extension,
5-
and therefore are not included with the `.h` extension.
6-
7-
Pre-standardized versions of C++ by Stroustrup used the `.h` extension, for example `iostream.h`,
8-
but this has been deprecated: <http://stackoverflow.com/questions/214230/iostream-vs-iostream-h-vs-iostream-h>
9-
It may still exits on certain systems, but never rely on it.
10-
11-
When writting new libs, you can use either `.h` or `.hpp` as extensions.
12-
13-
Prefer `.hpp` which indicates that the header is C++ specific, and not pure C.
14-
*/
1+
/* # Headers
2+
*
3+
* C++ stdlib headers that are not C stdlib headers don't have the `.h` extension,
4+
* and therefore are not included with the `.h` extension.
5+
*
6+
* Pre-standardized versions of C++ by Stroustrup used the `.h` extension, for example `iostream.h`,
7+
* but this has been deprecated: <http://stackoverflow.com/questions/214230/iostream-vs-iostream-h-vs-iostream-h>
8+
* It may still exits on certain systems, but never rely on it.
9+
*
10+
* When writing new libs, you can use either `.h` or `.hpp` as extensions.
11+
*
12+
* Prefer `.hpp` which indicates that the header is C++ specific, and not pure C.
13+
*/
1514

1615
#include <algorithm> // copy, erase, lower_bound, remove_if, swap, transform
1716
#include <bitset>
@@ -39,7 +38,6 @@
3938
#if __cplusplus >= 201103L
4039
#include <array> // array
4140
#include <atomic>
42-
#include <cassert>
4341
#include <chrono> // nanoseconds
4442
#include <mutex> // mutex
4543
#include <random>
@@ -53,34 +51,36 @@
5351
#include <unordered_map> // unordered_map, unordered_multimap
5452
#endif
5553

56-
/*
57-
# C headers
58-
59-
The standard C++ library provides a `cNAME` version to every `NAME.h` for every C header.
60-
E.g.: `math.h` vs `cmath`.
61-
62-
The difference is the following:
63-
64-
- cX puts things in std:: namespace. *always* use the CNAME version on new code,
65-
since this reduces the probability of a name conflicts, and is the standard c++ way of doing things.
66-
67-
Macro expansion happens *before* namespaces are even compiled,
68-
so you still refer to macros like `EXIT_SUCCESS` and `assert` as in C,
69-
and *not* as `std::EXIT_SUCCESS`.
70-
71-
- `X.h` puts *all* in the global namespace, it is exactly the same as the c headers.
72-
*never* use it in new code.
73-
74-
Those headers exist only for backwards compatibility.
75-
76-
Avoid using C headers and functionality altogether if that functionality has an equivalent C++ version,
77-
since the C++ version will play more nicely with new language features and libraries.
78-
79-
http://stackoverflow.com/questions/32606023/when-using-c-headers-in-c-should-we-use-functions-from-std-or-the-global-na
80-
*/
54+
/* # C headers
55+
*
56+
* The standard C++ library provides a `cNAME` version to every `NAME.h` for every C header.
57+
* E.g.: `math.h` vs `cmath`.
58+
*
59+
* The difference is the following:
60+
*
61+
* - cX puts things in std:: namespace. *always* use the CNAME version on new code,
62+
* since this reduces the probability of a name conflicts, and is the standard c++ way of doing things.
63+
*
64+
* Macro expansion happens *before* namespaces are even compiled,
65+
* so you still refer to macros like `EXIT_SUCCESS` and `assert` as in C,
66+
* and *not* as `std::EXIT_SUCCESS`.
67+
*
68+
* - `X.h` puts *all* in the global namespace, it is exactly the same as the c headers.
69+
* *never* use it in new code.
70+
*
71+
* Those headers exist only for backwards compatibility.
72+
*
73+
* Avoid using C headers and functionality altogether if that functionality has an equivalent C++ version,
74+
* since the C++ version will play more nicely with new language features and libraries.
75+
*
76+
* http://stackoverflow.com/questions/32606023/when-using-c-headers-in-c-should-we-use-functions-from-std-or-the-global-na
77+
*/
8178
#include <cmath>
8279
#include <cstdlib>
8380
#include <cstring>
81+
#if __cplusplus >= 201103L
82+
#include <cassert>
83+
#endif
8484

8585
// Global thread parameters.
8686
const int NUM_THREADS = 1000;
@@ -100,13 +100,12 @@ void printCallStack() {
100100
std::cout << "END callStack" << std::endl;
101101
}
102102

103-
/**
104-
* Simple instrumented class for tests on constructor destructor order.
103+
/* Simple instrumented class for tests on constructor destructor order.
105104
*
106105
* This class has no members which are objects and no base classes.
107106
*
108107
* TODO break this class up.
109-
* */
108+
*/
110109
class NoBaseNoMember {
111110
public:
112111

0 commit comments

Comments
 (0)