diff --git a/.clang-format b/.clang-format index dd1538725..8bd4cbd7e 100644 --- a/.clang-format +++ b/.clang-format @@ -43,7 +43,7 @@ PenaltyBreakFirstLessLess: 120 PenaltyBreakString: 1000 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 200 -PointerAlignment: Middle +PointerAlignment: Right SpaceAfterCStyleCast: false SpaceBeforeAssignmentOperators: true SpaceBeforeParens: ControlStatements diff --git a/Chapter01/recipe-03/cxx-example/Message.cpp b/Chapter01/recipe-03/cxx-example/Message.cpp index 986a93fc5..fef4278f9 100644 --- a/Chapter01/recipe-03/cxx-example/Message.cpp +++ b/Chapter01/recipe-03/cxx-example/Message.cpp @@ -3,7 +3,7 @@ #include #include -std::ostream & Message::printObject(std::ostream & os) { +std::ostream &Message::printObject(std::ostream &os) { os << "This is my very nice message: " << std::endl; os << message_; diff --git a/Chapter01/recipe-03/cxx-example/Message.hpp b/Chapter01/recipe-03/cxx-example/Message.hpp index 56f04bb38..8517a8729 100644 --- a/Chapter01/recipe-03/cxx-example/Message.hpp +++ b/Chapter01/recipe-03/cxx-example/Message.hpp @@ -5,13 +5,13 @@ class Message { public: - Message(const std::string & m) : message_(m) {} + Message(const std::string &m) : message_(m) {} - friend std::ostream & operator<<(std::ostream & os, Message & obj) { + friend std::ostream &operator<<(std::ostream &os, Message &obj) { return obj.printObject(os); } private: std::string message_; - std::ostream & printObject(std::ostream & os); + std::ostream &printObject(std::ostream &os); }; diff --git a/Chapter01/recipe-03/cxx-objlib-example/Message.cpp b/Chapter01/recipe-03/cxx-objlib-example/Message.cpp index 986a93fc5..fef4278f9 100644 --- a/Chapter01/recipe-03/cxx-objlib-example/Message.cpp +++ b/Chapter01/recipe-03/cxx-objlib-example/Message.cpp @@ -3,7 +3,7 @@ #include #include -std::ostream & Message::printObject(std::ostream & os) { +std::ostream &Message::printObject(std::ostream &os) { os << "This is my very nice message: " << std::endl; os << message_; diff --git a/Chapter01/recipe-03/cxx-objlib-example/Message.hpp b/Chapter01/recipe-03/cxx-objlib-example/Message.hpp index 56f04bb38..8517a8729 100644 --- a/Chapter01/recipe-03/cxx-objlib-example/Message.hpp +++ b/Chapter01/recipe-03/cxx-objlib-example/Message.hpp @@ -5,13 +5,13 @@ class Message { public: - Message(const std::string & m) : message_(m) {} + Message(const std::string &m) : message_(m) {} - friend std::ostream & operator<<(std::ostream & os, Message & obj) { + friend std::ostream &operator<<(std::ostream &os, Message &obj) { return obj.printObject(os); } private: std::string message_; - std::ostream & printObject(std::ostream & os); + std::ostream &printObject(std::ostream &os); }; diff --git a/Chapter01/recipe-04/cxx-example/Message.cpp b/Chapter01/recipe-04/cxx-example/Message.cpp index 986a93fc5..fef4278f9 100644 --- a/Chapter01/recipe-04/cxx-example/Message.cpp +++ b/Chapter01/recipe-04/cxx-example/Message.cpp @@ -3,7 +3,7 @@ #include #include -std::ostream & Message::printObject(std::ostream & os) { +std::ostream &Message::printObject(std::ostream &os) { os << "This is my very nice message: " << std::endl; os << message_; diff --git a/Chapter01/recipe-04/cxx-example/Message.hpp b/Chapter01/recipe-04/cxx-example/Message.hpp index 56f04bb38..8517a8729 100644 --- a/Chapter01/recipe-04/cxx-example/Message.hpp +++ b/Chapter01/recipe-04/cxx-example/Message.hpp @@ -5,13 +5,13 @@ class Message { public: - Message(const std::string & m) : message_(m) {} + Message(const std::string &m) : message_(m) {} - friend std::ostream & operator<<(std::ostream & os, Message & obj) { + friend std::ostream &operator<<(std::ostream &os, Message &obj) { return obj.printObject(os); } private: std::string message_; - std::ostream & printObject(std::ostream & os); + std::ostream &printObject(std::ostream &os); }; diff --git a/Chapter01/recipe-06/cxx-example/Message.cpp b/Chapter01/recipe-06/cxx-example/Message.cpp index 986a93fc5..fef4278f9 100644 --- a/Chapter01/recipe-06/cxx-example/Message.cpp +++ b/Chapter01/recipe-06/cxx-example/Message.cpp @@ -3,7 +3,7 @@ #include #include -std::ostream & Message::printObject(std::ostream & os) { +std::ostream &Message::printObject(std::ostream &os) { os << "This is my very nice message: " << std::endl; os << message_; diff --git a/Chapter01/recipe-06/cxx-example/Message.hpp b/Chapter01/recipe-06/cxx-example/Message.hpp index 56f04bb38..8517a8729 100644 --- a/Chapter01/recipe-06/cxx-example/Message.hpp +++ b/Chapter01/recipe-06/cxx-example/Message.hpp @@ -5,13 +5,13 @@ class Message { public: - Message(const std::string & m) : message_(m) {} + Message(const std::string &m) : message_(m) {} - friend std::ostream & operator<<(std::ostream & os, Message & obj) { + friend std::ostream &operator<<(std::ostream &os, Message &obj) { return obj.printObject(os); } private: std::string message_; - std::ostream & printObject(std::ostream & os); + std::ostream &printObject(std::ostream &os); }; diff --git a/Chapter01/recipe-10/cxx-example/Animal.cpp b/Chapter01/recipe-10/cxx-example/Animal.cpp index 86f4e4591..fd5bd751b 100644 --- a/Chapter01/recipe-10/cxx-example/Animal.cpp +++ b/Chapter01/recipe-10/cxx-example/Animal.cpp @@ -2,6 +2,6 @@ #include -Animal::Animal(const std::string & n) : name_(n) {} +Animal::Animal(const std::string &n) : name_(n) {} std::string Animal::name() const { return name_impl(); } diff --git a/Chapter01/recipe-10/cxx-example/Animal.hpp b/Chapter01/recipe-10/cxx-example/Animal.hpp index de983a4a2..121a91121 100644 --- a/Chapter01/recipe-10/cxx-example/Animal.hpp +++ b/Chapter01/recipe-10/cxx-example/Animal.hpp @@ -5,7 +5,7 @@ class Animal { public: Animal() = delete; - explicit Animal(const std::string & n); + explicit Animal(const std::string &n); std::string name() const; protected: diff --git a/Chapter01/recipe-10/cxx-example/Cat.hpp b/Chapter01/recipe-10/cxx-example/Cat.hpp index 0a383eecb..0b4272597 100644 --- a/Chapter01/recipe-10/cxx-example/Cat.hpp +++ b/Chapter01/recipe-10/cxx-example/Cat.hpp @@ -4,7 +4,7 @@ class Cat final : public Animal { public: - Cat(const std::string & n) : Animal(n) {} + Cat(const std::string &n) : Animal(n) {} private: std::string name_impl() const override; diff --git a/Chapter01/recipe-10/cxx-example/Dog.hpp b/Chapter01/recipe-10/cxx-example/Dog.hpp index 2e0e4d4f8..079155771 100644 --- a/Chapter01/recipe-10/cxx-example/Dog.hpp +++ b/Chapter01/recipe-10/cxx-example/Dog.hpp @@ -4,7 +4,7 @@ class Dog final : public Animal { public: - Dog(const std::string & n) : Animal(n) {} + Dog(const std::string &n) : Animal(n) {} private: std::string name_impl() const override; diff --git a/Chapter01/recipe-10/cxx-example/Factory.hpp b/Chapter01/recipe-10/cxx-example/Factory.hpp index 09f3350cf..d73923eb6 100644 --- a/Chapter01/recipe-10/cxx-example/Factory.hpp +++ b/Chapter01/recipe-10/cxx-example/Factory.hpp @@ -44,7 +44,7 @@ template class BaseFactory { /*! \brief Retrieve constant iterator from map given object identifier * \param[in] objID the object's identification string */ - CallbackConstIter retrieve(const std::string & objID) const { + CallbackConstIter retrieve(const std::string &objID) const { if (objID.empty()) ERROR("No object identification string provided to the Factory."); CallbackConstIter i = callbacks_.find(objID); @@ -58,13 +58,13 @@ template class BaseFactory { * \param[in] objID the object's identification string * \param[in] functor the creation function related to the object type given */ - bool registerObject(const std::string & objID, const CreateObject & functor) { + bool registerObject(const std::string &objID, const CreateObject &functor) { return callbacks_.insert(CallbackPair(objID, functor)).second; } /*! \brief Returns true if objID was already registered * \param objID the object's identification string */ - bool unRegisterObject(const std::string & objID) { + bool unRegisterObject(const std::string &objID) { return callbacks_.erase(objID) == 1; } @@ -73,7 +73,7 @@ template class BaseFactory { * \param[in] objID the object's identification string * \param[in] functor the creation function related to the object type given */ - void subscribe(const std::string & objID, const CreateObject & functor) { + void subscribe(const std::string &objID, const CreateObject &functor) { bool done = this->registerObject(objID, functor); if (!done) ERROR("Subscription of object ID " + objID + " to factory failed!"); @@ -81,7 +81,7 @@ template class BaseFactory { /*! \brief Unsubscribes object with objID from factory * \param objID the object's identification string */ - void unsubscribe(const std::string & objID) { + void unsubscribe(const std::string &objID) { bool done = this->unRegisterObject(objID); if (!done) ERROR("Unsubscription of object ID " + objID + " from factory failed!"); @@ -113,7 +113,7 @@ class Factory final : public detail::BaseFactory { */ template typename std::result_of::type create( - const std::string & objID, + const std::string &objID, ObjectInputArgs... data) const { return (this->retrieve(objID)->second)(data...); } diff --git a/Chapter01/recipe-10/cxx-example/animal-farm.cpp b/Chapter01/recipe-10/cxx-example/animal-farm.cpp index 062bcad75..8e6b169b9 100644 --- a/Chapter01/recipe-10/cxx-example/animal-farm.cpp +++ b/Chapter01/recipe-10/cxx-example/animal-farm.cpp @@ -13,9 +13,9 @@ typedef std::function(const std::string &)> CreateAnimal int main() { Factory farm; farm.subscribe("CAT", - [](const std::string & n) { return std::make_unique(n); }); + [](const std::string &n) { return std::make_unique(n); }); farm.subscribe("DOG", - [](const std::string & n) { return std::make_unique(n); }); + [](const std::string &n) { return std::make_unique(n); }); std::unique_ptr simon = farm.create("CAT", "Simon"); std::unique_ptr marlowe = farm.create("DOG", "Marlowe"); diff --git a/Chapter03/recipe-03/cxx-example/Py2-pure-embedding.cpp b/Chapter03/recipe-03/cxx-example/Py2-pure-embedding.cpp index ed049800c..da5da6e0c 100644 --- a/Chapter03/recipe-03/cxx-example/Py2-pure-embedding.cpp +++ b/Chapter03/recipe-03/cxx-example/Py2-pure-embedding.cpp @@ -5,7 +5,7 @@ #include -int main(int argc, char * argv[]) { +int main(int argc, char *argv[]) { PyObject *pName, *pModule, *pDict, *pFunc; PyObject *pArgs, *pValue; int i; diff --git a/Chapter03/recipe-03/cxx-example/Py3-pure-embedding.cpp b/Chapter03/recipe-03/cxx-example/Py3-pure-embedding.cpp index ee8aad385..d9a170e32 100644 --- a/Chapter03/recipe-03/cxx-example/Py3-pure-embedding.cpp +++ b/Chapter03/recipe-03/cxx-example/Py3-pure-embedding.cpp @@ -5,7 +5,7 @@ #include -int main(int argc, char * argv[]) { +int main(int argc, char *argv[]) { PyObject *pName, *pModule, *pDict, *pFunc; PyObject *pArgs, *pValue; int i; diff --git a/Chapter03/recipe-04/cxx-example/CxxBLAS.cpp b/Chapter03/recipe-04/cxx-example/CxxBLAS.cpp index 75248128d..3972ce041 100644 --- a/Chapter03/recipe-04/cxx-example/CxxBLAS.cpp +++ b/Chapter03/recipe-04/cxx-example/CxxBLAS.cpp @@ -122,23 +122,23 @@ void C_DGEMM(char transa, int n, int k, double alpha, - double * a, + double *a, int lda, - double * b, + double *b, int ldb, double beta, - double * c, + double *c, int ldc) { if (m == 0 || n == 0 || k == 0) return; ::F_DGEMM(&transb, &transa, &n, &m, &k, &alpha, b, &ldb, a, &lda, &beta, c, &ldc); } -void C_DSCAL(size_t length, double alpha, double * vec, int inc) { +void C_DSCAL(size_t length, double alpha, double *vec, int inc) { int big_blocks = (int)(length / INT_MAX); int small_size = (int)(length % INT_MAX); for (int block = 0; block <= big_blocks; block++) { - double * vec_s = &vec[block * inc * (size_t)INT_MAX]; + double *vec_s = &vec[block * inc * (size_t)INT_MAX]; signed int length_s = (block == big_blocks) ? small_size : INT_MAX; ::F_DSCAL(&length_s, &alpha, vec_s, &inc); } diff --git a/Chapter03/recipe-04/cxx-example/CxxBLAS.hpp b/Chapter03/recipe-04/cxx-example/CxxBLAS.hpp index 1d7af0ee8..6e8a97497 100644 --- a/Chapter03/recipe-04/cxx-example/CxxBLAS.hpp +++ b/Chapter03/recipe-04/cxx-example/CxxBLAS.hpp @@ -25,7 +25,7 @@ extern void F_DGEMM(char *, int *); #define F_DSCAL dscal_ -extern void F_DSCAL(int * n, double * alpha, double * vec, int * inc); +extern void F_DSCAL(int *n, double *alpha, double *vec, int *inc); #ifdef __cplusplus } @@ -37,12 +37,12 @@ void C_DGEMM(char transa, int n, int k, double alpha, - double * a, + double *a, int lda, - double * b, + double *b, int ldb, double beta, - double * c, + double *c, int ldc); /*! @@ -54,4 +54,4 @@ void C_DGEMM(char transa, * \param inc how many places to skip to get to next element in vec * */ -void C_DSCAL(size_t length, double alpha, double * vec, int inc); +void C_DSCAL(size_t length, double alpha, double *vec, int inc); diff --git a/Chapter03/recipe-04/cxx-example/CxxLAPACK.cpp b/Chapter03/recipe-04/cxx-example/CxxLAPACK.cpp index d722d5a78..bbb4043fd 100644 --- a/Chapter03/recipe-04/cxx-example/CxxLAPACK.cpp +++ b/Chapter03/recipe-04/cxx-example/CxxLAPACK.cpp @@ -55,7 +55,7 @@ * singular, so the solution could not be computed. * */ -int C_DGESV(int n, int nrhs, double * a, int lda, int * ipiv, double * b, int ldb) { +int C_DGESV(int n, int nrhs, double *a, int lda, int *ipiv, double *b, int ldb) { int info; ::F_DGESV(&n, &nrhs, a, &lda, ipiv, b, &ldb, &info); return info; @@ -101,10 +101,10 @@ int C_DGESV(int n, int nrhs, double * a, int lda, int * ipiv, double * b, int ld int C_DSYEV(char jobz, char uplo, int n, - double * A, + double *A, int lda, - double * w, - double * work, + double *w, + double *work, int lwork) { int info; diff --git a/Chapter03/recipe-04/cxx-example/CxxLAPACK.hpp b/Chapter03/recipe-04/cxx-example/CxxLAPACK.hpp index 9a855bed3..8291540c2 100644 --- a/Chapter03/recipe-04/cxx-example/CxxLAPACK.hpp +++ b/Chapter03/recipe-04/cxx-example/CxxLAPACK.hpp @@ -18,13 +18,13 @@ F_DSYEV(char *, char *, int *, double *, int *, double *, double *, int *, int * } #endif -int C_DGESV(int n, int nrhs, double * a, int lda, int * ipiv, double * b, int ldb); +int C_DGESV(int n, int nrhs, double *a, int lda, int *ipiv, double *b, int ldb); int C_DSYEV(char jobz, char uplo, int n, - double * a, + double *a, int lda, - double * w, - double * work, + double *w, + double *work, int lwork); diff --git a/Chapter03/recipe-04/cxx-example/linear-algebra.cpp b/Chapter03/recipe-04/cxx-example/linear-algebra.cpp index 63738f98e..fca445e37 100644 --- a/Chapter03/recipe-04/cxx-example/linear-algebra.cpp +++ b/Chapter03/recipe-04/cxx-example/linear-algebra.cpp @@ -10,7 +10,7 @@ #include "CxxBLAS.hpp" #include "CxxLAPACK.hpp" -int main(int argc, char ** argv) { +int main(int argc, char **argv) { if (argc != 2) { std::cout << "Usage: ./linear-algebra dim" << std::endl; return EXIT_FAILURE; diff --git a/Chapter03/recipe-05/cxx-example/hello-openmp.cpp b/Chapter03/recipe-05/cxx-example/hello-openmp.cpp index 6f5850339..da67b469f 100644 --- a/Chapter03/recipe-05/cxx-example/hello-openmp.cpp +++ b/Chapter03/recipe-05/cxx-example/hello-openmp.cpp @@ -21,7 +21,7 @@ * Roberto Di Remigio */ -int main(int argc, char * argv[]) { +int main(int argc, char *argv[]) { std::cout << "\n"; std::cout << "HELLO_OPENMP" << std::endl; std::cout << " C++11/OpenMP version" << std::endl; diff --git a/Chapter03/recipe-06/cxx-example/hello-mpi.cpp b/Chapter03/recipe-06/cxx-example/hello-mpi.cpp index df314dab6..ff3c3fffa 100644 --- a/Chapter03/recipe-06/cxx-example/hello-mpi.cpp +++ b/Chapter03/recipe-06/cxx-example/hello-mpi.cpp @@ -12,7 +12,7 @@ #include -int main(int argc, char ** argv) { +int main(int argc, char **argv) { // Initialize the MPI environment. The two arguments to MPI Init are not // currently used by MPI implementations, but are there in case future // implementations might need the arguments. diff --git a/Chapter03/recipe-07/cxx-example/linear-algebra.cpp b/Chapter03/recipe-07/cxx-example/linear-algebra.cpp index 4889b7f01..e566e4d31 100644 --- a/Chapter03/recipe-07/cxx-example/linear-algebra.cpp +++ b/Chapter03/recipe-07/cxx-example/linear-algebra.cpp @@ -6,7 +6,7 @@ #include -int main(int argc, char ** argv) { +int main(int argc, char **argv) { if (argc != 2) { std::cout << "Usage: ./linear-algebra dim" << std::endl; return EXIT_FAILURE; diff --git a/Chapter03/recipe-08/cxx-example/path-info.cpp b/Chapter03/recipe-08/cxx-example/path-info.cpp index fd3e44efb..ed0f51649 100644 --- a/Chapter03/recipe-08/cxx-example/path-info.cpp +++ b/Chapter03/recipe-08/cxx-example/path-info.cpp @@ -15,9 +15,9 @@ using namespace std; using namespace boost::filesystem; -const char * say_what(bool b) { return b ? "true" : "false"; } +const char *say_what(bool b) { return b ? "true" : "false"; } -int main(int argc, char * argv[]) { +int main(int argc, char *argv[]) { if (argc < 2) { cout << "Usage: path_info path-element [path-element...]\n" diff --git a/Chapter04/recipe-01/cxx-example/main.cpp b/Chapter04/recipe-01/cxx-example/main.cpp index 0cea5e9c5..520a1bce0 100644 --- a/Chapter04/recipe-01/cxx-example/main.cpp +++ b/Chapter04/recipe-01/cxx-example/main.cpp @@ -5,7 +5,7 @@ // we assume all arguments are integers and we sum them up // for simplicity we do not verify the type of arguments -int main(int argc, char * argv[]) { +int main(int argc, char *argv[]) { std::vector integers; for (int i = 1; i < argc; i++) { diff --git a/Chapter04/recipe-01/cxx-example/sum_integers.cpp b/Chapter04/recipe-01/cxx-example/sum_integers.cpp index 6a9f33d8c..6fbe1327d 100644 --- a/Chapter04/recipe-01/cxx-example/sum_integers.cpp +++ b/Chapter04/recipe-01/cxx-example/sum_integers.cpp @@ -4,7 +4,7 @@ int sum_integers(const std::vector integers) { int sum = 0; - for (auto & i : integers) { + for (auto &i : integers) { sum += i; } return sum; diff --git a/Chapter04/recipe-03/cxx-example/test.cpp b/Chapter04/recipe-03/cxx-example/test.cpp index 683e7756c..8c15d7869 100644 --- a/Chapter04/recipe-03/cxx-example/test.cpp +++ b/Chapter04/recipe-03/cxx-example/test.cpp @@ -3,7 +3,7 @@ #include "sum_integers.h" #include "gtest/gtest.h" -int main(int argc, char ** argv) { +int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/Chapter04/recipe-05/cxx-example/leaky_implementation.cpp b/Chapter04/recipe-05/cxx-example/leaky_implementation.cpp index 92e854ebe..9175ec214 100644 --- a/Chapter04/recipe-05/cxx-example/leaky_implementation.cpp +++ b/Chapter04/recipe-05/cxx-example/leaky_implementation.cpp @@ -3,7 +3,7 @@ int do_some_work() { // we allocate an array - double * my_array; + double *my_array; my_array = new double[1000]; // do some work diff --git a/Chapter05/recipe-01/cxx-example/linear-algebra.cpp b/Chapter05/recipe-01/cxx-example/linear-algebra.cpp index 4889b7f01..e566e4d31 100644 --- a/Chapter05/recipe-01/cxx-example/linear-algebra.cpp +++ b/Chapter05/recipe-01/cxx-example/linear-algebra.cpp @@ -6,7 +6,7 @@ #include -int main(int argc, char ** argv) { +int main(int argc, char **argv) { if (argc != 2) { std::cout << "Usage: ./linear-algebra dim" << std::endl; return EXIT_FAILURE; diff --git a/Chapter05/recipe-02/cxx-example/Py2-pure-embedding.cpp b/Chapter05/recipe-02/cxx-example/Py2-pure-embedding.cpp index c2717a1f8..d54b357fd 100644 --- a/Chapter05/recipe-02/cxx-example/Py2-pure-embedding.cpp +++ b/Chapter05/recipe-02/cxx-example/Py2-pure-embedding.cpp @@ -7,7 +7,7 @@ #include "Report.hpp" -int main(int argc, char * argv[]) { +int main(int argc, char *argv[]) { PyObject *pName, *pModule, *pDict, *pFunc; PyObject *pArgs, *pValue; int i; diff --git a/Chapter05/recipe-02/cxx-example/Py3-pure-embedding.cpp b/Chapter05/recipe-02/cxx-example/Py3-pure-embedding.cpp index 23b477c2c..aa20ef663 100644 --- a/Chapter05/recipe-02/cxx-example/Py3-pure-embedding.cpp +++ b/Chapter05/recipe-02/cxx-example/Py3-pure-embedding.cpp @@ -7,7 +7,7 @@ #include "Report.hpp" -int main(int argc, char * argv[]) { +int main(int argc, char *argv[]) { PyObject *pName, *pModule, *pDict, *pFunc; PyObject *pArgs, *pValue; int i; diff --git a/Chapter05/recipe-03/cxx-example/linear-algebra.cpp b/Chapter05/recipe-03/cxx-example/linear-algebra.cpp index 63738f98e..fca445e37 100644 --- a/Chapter05/recipe-03/cxx-example/linear-algebra.cpp +++ b/Chapter05/recipe-03/cxx-example/linear-algebra.cpp @@ -10,7 +10,7 @@ #include "CxxBLAS.hpp" #include "CxxLAPACK.hpp" -int main(int argc, char ** argv) { +int main(int argc, char **argv) { if (argc != 2) { std::cout << "Usage: ./linear-algebra dim" << std::endl; return EXIT_FAILURE; diff --git a/Chapter05/recipe-04/cxx-example/linear-algebra.cpp b/Chapter05/recipe-04/cxx-example/linear-algebra.cpp index 63738f98e..fca445e37 100644 --- a/Chapter05/recipe-04/cxx-example/linear-algebra.cpp +++ b/Chapter05/recipe-04/cxx-example/linear-algebra.cpp @@ -10,7 +10,7 @@ #include "CxxBLAS.hpp" #include "CxxLAPACK.hpp" -int main(int argc, char ** argv) { +int main(int argc, char **argv) { if (argc != 2) { std::cout << "Usage: ./linear-algebra dim" << std::endl; return EXIT_FAILURE; diff --git a/Chapter05/recipe-05/cxx-example/Py2-pure-embedding.cpp b/Chapter05/recipe-05/cxx-example/Py2-pure-embedding.cpp index ed049800c..da5da6e0c 100644 --- a/Chapter05/recipe-05/cxx-example/Py2-pure-embedding.cpp +++ b/Chapter05/recipe-05/cxx-example/Py2-pure-embedding.cpp @@ -5,7 +5,7 @@ #include -int main(int argc, char * argv[]) { +int main(int argc, char *argv[]) { PyObject *pName, *pModule, *pDict, *pFunc; PyObject *pArgs, *pValue; int i; diff --git a/Chapter05/recipe-05/cxx-example/Py3-pure-embedding.cpp b/Chapter05/recipe-05/cxx-example/Py3-pure-embedding.cpp index ee8aad385..d9a170e32 100644 --- a/Chapter05/recipe-05/cxx-example/Py3-pure-embedding.cpp +++ b/Chapter05/recipe-05/cxx-example/Py3-pure-embedding.cpp @@ -5,7 +5,7 @@ #include -int main(int argc, char * argv[]) { +int main(int argc, char *argv[]) { PyObject *pName, *pModule, *pDict, *pFunc; PyObject *pArgs, *pValue; int i; diff --git a/Chapter05/recipe-07/cxx-example/asan-example.cpp b/Chapter05/recipe-07/cxx-example/asan-example.cpp index 6232f6269..8c2fc3a24 100644 --- a/Chapter05/recipe-07/cxx-example/asan-example.cpp +++ b/Chapter05/recipe-07/cxx-example/asan-example.cpp @@ -1,4 +1,4 @@ -int main(int argc, char ** argv) { +int main(int argc, char **argv) { int stack_array[100]; stack_array[1] = 0; return stack_array[argc + 100]; // BOOM diff --git a/Chapter05/recipe-07/cxx-example/msan-example.cpp b/Chapter05/recipe-07/cxx-example/msan-example.cpp index c15cf0134..efd987708 100644 --- a/Chapter05/recipe-07/cxx-example/msan-example.cpp +++ b/Chapter05/recipe-07/cxx-example/msan-example.cpp @@ -1,7 +1,7 @@ #include -int main(int argc, char ** argv) { - int * a = new int[10]; +int main(int argc, char **argv) { + int *a = new int[10]; a[5] = 0; volatile int b = a[argc]; if (b) diff --git a/Chapter05/recipe-07/cxx-example/tsan-example.cpp b/Chapter05/recipe-07/cxx-example/tsan-example.cpp index fd681cf07..5c63f694e 100644 --- a/Chapter05/recipe-07/cxx-example/tsan-example.cpp +++ b/Chapter05/recipe-07/cxx-example/tsan-example.cpp @@ -5,8 +5,8 @@ typedef std::map map_t; -void * threadfunc(void * p) { - map_t & m = *(map_t *)p; +void *threadfunc(void *p) { + map_t &m = *(map_t *)p; m["foo"] = "bar"; return 0; } diff --git a/Chapter05/recipe-07/cxx-example/ubsan-example.cpp b/Chapter05/recipe-07/cxx-example/ubsan-example.cpp index c4f0ed06e..3a3e5a480 100644 --- a/Chapter05/recipe-07/cxx-example/ubsan-example.cpp +++ b/Chapter05/recipe-07/cxx-example/ubsan-example.cpp @@ -1,4 +1,4 @@ -int main(int argc, char ** argv) { +int main(int argc, char **argv) { int k = 0x7fffffff; k += argc; return 0; diff --git a/Chapter05/recipe-09/cxx-example/asan-example.cpp b/Chapter05/recipe-09/cxx-example/asan-example.cpp index 6232f6269..8c2fc3a24 100644 --- a/Chapter05/recipe-09/cxx-example/asan-example.cpp +++ b/Chapter05/recipe-09/cxx-example/asan-example.cpp @@ -1,4 +1,4 @@ -int main(int argc, char ** argv) { +int main(int argc, char **argv) { int stack_array[100]; stack_array[1] = 0; return stack_array[argc + 100]; // BOOM diff --git a/Chapter09/recipe-02/cxx-example/src/linalg_wrap/CxxBLAS.cpp b/Chapter09/recipe-02/cxx-example/src/linalg_wrap/CxxBLAS.cpp index 75248128d..3972ce041 100644 --- a/Chapter09/recipe-02/cxx-example/src/linalg_wrap/CxxBLAS.cpp +++ b/Chapter09/recipe-02/cxx-example/src/linalg_wrap/CxxBLAS.cpp @@ -122,23 +122,23 @@ void C_DGEMM(char transa, int n, int k, double alpha, - double * a, + double *a, int lda, - double * b, + double *b, int ldb, double beta, - double * c, + double *c, int ldc) { if (m == 0 || n == 0 || k == 0) return; ::F_DGEMM(&transb, &transa, &n, &m, &k, &alpha, b, &ldb, a, &lda, &beta, c, &ldc); } -void C_DSCAL(size_t length, double alpha, double * vec, int inc) { +void C_DSCAL(size_t length, double alpha, double *vec, int inc) { int big_blocks = (int)(length / INT_MAX); int small_size = (int)(length % INT_MAX); for (int block = 0; block <= big_blocks; block++) { - double * vec_s = &vec[block * inc * (size_t)INT_MAX]; + double *vec_s = &vec[block * inc * (size_t)INT_MAX]; signed int length_s = (block == big_blocks) ? small_size : INT_MAX; ::F_DSCAL(&length_s, &alpha, vec_s, &inc); } diff --git a/Chapter09/recipe-02/cxx-example/src/linalg_wrap/CxxBLAS.hpp b/Chapter09/recipe-02/cxx-example/src/linalg_wrap/CxxBLAS.hpp index 469455ec6..bb2ce6158 100644 --- a/Chapter09/recipe-02/cxx-example/src/linalg_wrap/CxxBLAS.hpp +++ b/Chapter09/recipe-02/cxx-example/src/linalg_wrap/CxxBLAS.hpp @@ -27,7 +27,7 @@ extern void F_DGEMM(char *, int *); #define F_DSCAL FortranCInterface_GLOBAL(dscal, DSCAL) -extern void F_DSCAL(int * n, double * alpha, double * vec, int * inc); +extern void F_DSCAL(int *n, double *alpha, double *vec, int *inc); #ifdef __cplusplus } @@ -39,12 +39,12 @@ void C_DGEMM(char transa, int n, int k, double alpha, - double * a, + double *a, int lda, - double * b, + double *b, int ldb, double beta, - double * c, + double *c, int ldc); /*! @@ -56,4 +56,4 @@ void C_DGEMM(char transa, * \param inc how many places to skip to get to next element in vec * */ -void C_DSCAL(size_t length, double alpha, double * vec, int inc); +void C_DSCAL(size_t length, double alpha, double *vec, int inc); diff --git a/Chapter09/recipe-02/cxx-example/src/linalg_wrap/CxxLAPACK.cpp b/Chapter09/recipe-02/cxx-example/src/linalg_wrap/CxxLAPACK.cpp index d722d5a78..bbb4043fd 100644 --- a/Chapter09/recipe-02/cxx-example/src/linalg_wrap/CxxLAPACK.cpp +++ b/Chapter09/recipe-02/cxx-example/src/linalg_wrap/CxxLAPACK.cpp @@ -55,7 +55,7 @@ * singular, so the solution could not be computed. * */ -int C_DGESV(int n, int nrhs, double * a, int lda, int * ipiv, double * b, int ldb) { +int C_DGESV(int n, int nrhs, double *a, int lda, int *ipiv, double *b, int ldb) { int info; ::F_DGESV(&n, &nrhs, a, &lda, ipiv, b, &ldb, &info); return info; @@ -101,10 +101,10 @@ int C_DGESV(int n, int nrhs, double * a, int lda, int * ipiv, double * b, int ld int C_DSYEV(char jobz, char uplo, int n, - double * A, + double *A, int lda, - double * w, - double * work, + double *w, + double *work, int lwork) { int info; diff --git a/Chapter09/recipe-02/cxx-example/src/linalg_wrap/CxxLAPACK.hpp b/Chapter09/recipe-02/cxx-example/src/linalg_wrap/CxxLAPACK.hpp index dcae5454a..54ff3a9d1 100644 --- a/Chapter09/recipe-02/cxx-example/src/linalg_wrap/CxxLAPACK.hpp +++ b/Chapter09/recipe-02/cxx-example/src/linalg_wrap/CxxLAPACK.hpp @@ -20,13 +20,13 @@ F_DSYEV(char *, char *, int *, double *, int *, double *, double *, int *, int * } #endif -int C_DGESV(int n, int nrhs, double * a, int lda, int * ipiv, double * b, int ldb); +int C_DGESV(int n, int nrhs, double *a, int lda, int *ipiv, double *b, int ldb); int C_DSYEV(char jobz, char uplo, int n, - double * a, + double *a, int lda, - double * w, - double * work, + double *w, + double *work, int lwork); diff --git a/Chapter09/recipe-02/cxx-example/src/linear-algebra.cpp b/Chapter09/recipe-02/cxx-example/src/linear-algebra.cpp index 63738f98e..fca445e37 100644 --- a/Chapter09/recipe-02/cxx-example/src/linear-algebra.cpp +++ b/Chapter09/recipe-02/cxx-example/src/linear-algebra.cpp @@ -10,7 +10,7 @@ #include "CxxBLAS.hpp" #include "CxxLAPACK.hpp" -int main(int argc, char ** argv) { +int main(int argc, char **argv) { if (argc != 2) { std::cout << "Usage: ./linear-algebra dim" << std::endl; return EXIT_FAILURE; diff --git a/to-triage/cxx-objlib-example/Message.cpp b/to-triage/cxx-objlib-example/Message.cpp index 986a93fc5..fef4278f9 100644 --- a/to-triage/cxx-objlib-example/Message.cpp +++ b/to-triage/cxx-objlib-example/Message.cpp @@ -3,7 +3,7 @@ #include #include -std::ostream & Message::printObject(std::ostream & os) { +std::ostream &Message::printObject(std::ostream &os) { os << "This is my very nice message: " << std::endl; os << message_; diff --git a/to-triage/cxx-objlib-example/Message.hpp b/to-triage/cxx-objlib-example/Message.hpp index 56f04bb38..8517a8729 100644 --- a/to-triage/cxx-objlib-example/Message.hpp +++ b/to-triage/cxx-objlib-example/Message.hpp @@ -5,13 +5,13 @@ class Message { public: - Message(const std::string & m) : message_(m) {} + Message(const std::string &m) : message_(m) {} - friend std::ostream & operator<<(std::ostream & os, Message & obj) { + friend std::ostream &operator<<(std::ostream &os, Message &obj) { return obj.printObject(os); } private: std::string message_; - std::ostream & printObject(std::ostream & os); + std::ostream &printObject(std::ostream &os); }; diff --git a/to-triage/strong-types/Addable.hpp b/to-triage/strong-types/Addable.hpp index 60144b37e..9b3ad9138 100644 --- a/to-triage/strong-types/Addable.hpp +++ b/to-triage/strong-types/Addable.hpp @@ -3,5 +3,5 @@ #include "CRTP.hpp" template struct Addable : CRTP { - T operator+(T const & other) { return T(this->underlying().get() + other.get()); } + T operator+(T const &other) { return T(this->underlying().get() + other.get()); } }; diff --git a/to-triage/strong-types/CRTP.hpp b/to-triage/strong-types/CRTP.hpp index 4c8cd5bee..6198a2252 100644 --- a/to-triage/strong-types/CRTP.hpp +++ b/to-triage/strong-types/CRTP.hpp @@ -1,6 +1,6 @@ #pragma once template class Policy> struct CRTP { - T & underlying() { return static_cast(*this); } - T const & underlying() const { return static_cast(*this); } + T &underlying() { return static_cast(*this); } + T const &underlying() const { return static_cast(*this); } }; diff --git a/to-triage/strong-types/Incrementable.hpp b/to-triage/strong-types/Incrementable.hpp index 550c91262..530ae5191 100644 --- a/to-triage/strong-types/Incrementable.hpp +++ b/to-triage/strong-types/Incrementable.hpp @@ -3,7 +3,7 @@ #include "CRTP.hpp" template struct Incrementable : CRTP { - T & operator+=(T const & other) { + T &operator+=(T const &other) { this->underlying().get() += other.get(); return this->underlying(); } diff --git a/to-triage/strong-types/Multiplicable.hpp b/to-triage/strong-types/Multiplicable.hpp index a3712a8b8..a8eb92452 100644 --- a/to-triage/strong-types/Multiplicable.hpp +++ b/to-triage/strong-types/Multiplicable.hpp @@ -3,5 +3,5 @@ #include "CRTP.hpp" template struct Multiplicable : CRTP { - T operator*(T const & other) { return T(this->underlying().get() * other.get()); } + T operator*(T const &other) { return T(this->underlying().get() * other.get()); } }; diff --git a/to-triage/strong-types/NamedType.hpp b/to-triage/strong-types/NamedType.hpp index 31cf4a764..f61ed33a3 100644 --- a/to-triage/strong-types/NamedType.hpp +++ b/to-triage/strong-types/NamedType.hpp @@ -3,18 +3,18 @@ template class... Policies> class NamedType : public Policies>... { public: - explicit NamedType(T const & value) : value_(value) {} - explicit NamedType(T && value) : value_(value) {} - T & get() { return value_; } - T const & get() const { return value_; } + explicit NamedType(T const &value) : value_(value) {} + explicit NamedType(T &&value) : value_(value) {} + T &get() { return value_; } + T const &get() const { return value_; } private: T value_; }; template class... Policies> -std::ostream & operator<<(std::ostream & os, - NamedType const & object) { +std::ostream &operator<<(std::ostream &os, + NamedType const &object) { object.print(os); return os; } diff --git a/to-triage/strong-types/Printable.hpp b/to-triage/strong-types/Printable.hpp index 0eef64a99..62ba07f13 100644 --- a/to-triage/strong-types/Printable.hpp +++ b/to-triage/strong-types/Printable.hpp @@ -3,5 +3,5 @@ #include "CRTP.hpp" template struct Printable : CRTP { - void print(std::ostream & os) const { os << this->underlying().get(); } + void print(std::ostream &os) const { os << this->underlying().get(); } };