Skip to content

Commit

Permalink
switching to right-aligned pointer; closes dev-cafe#208
Browse files Browse the repository at this point in the history
this is also consistent with google c++ style guide
  • Loading branch information
bast committed Dec 29, 2017
1 parent 1d28eb4 commit 7991e10
Show file tree
Hide file tree
Showing 55 changed files with 108 additions and 108 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Middle
PointerAlignment: Right
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
Expand Down
2 changes: 1 addition & 1 deletion Chapter01/recipe-03/cxx-example/Message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <iostream>
#include <string>

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_;

Expand Down
6 changes: 3 additions & 3 deletions Chapter01/recipe-03/cxx-example/Message.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
2 changes: 1 addition & 1 deletion Chapter01/recipe-03/cxx-objlib-example/Message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <iostream>
#include <string>

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_;

Expand Down
6 changes: 3 additions & 3 deletions Chapter01/recipe-03/cxx-objlib-example/Message.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
2 changes: 1 addition & 1 deletion Chapter01/recipe-04/cxx-example/Message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <iostream>
#include <string>

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_;

Expand Down
6 changes: 3 additions & 3 deletions Chapter01/recipe-04/cxx-example/Message.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
2 changes: 1 addition & 1 deletion Chapter01/recipe-06/cxx-example/Message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <iostream>
#include <string>

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_;

Expand Down
6 changes: 3 additions & 3 deletions Chapter01/recipe-06/cxx-example/Message.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
2 changes: 1 addition & 1 deletion Chapter01/recipe-10/cxx-example/Animal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

#include <string>

Animal::Animal(const std::string & n) : name_(n) {}
Animal::Animal(const std::string &n) : name_(n) {}

std::string Animal::name() const { return name_impl(); }
2 changes: 1 addition & 1 deletion Chapter01/recipe-10/cxx-example/Animal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Chapter01/recipe-10/cxx-example/Cat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Chapter01/recipe-10/cxx-example/Dog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions Chapter01/recipe-10/cxx-example/Factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ template <typename CreateObject> 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);
Expand All @@ -58,13 +58,13 @@ template <typename CreateObject> 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;
}

Expand All @@ -73,15 +73,15 @@ template <typename CreateObject> 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!");
}
/*! \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!");
Expand Down Expand Up @@ -113,7 +113,7 @@ class Factory final : public detail::BaseFactory<CreateObject> {
*/
template <typename... ObjectInputArgs>
typename std::result_of<CreateObject(ObjectInputArgs...)>::type create(
const std::string & objID,
const std::string &objID,
ObjectInputArgs... data) const {
return (this->retrieve(objID)->second)(data...);
}
Expand Down
4 changes: 2 additions & 2 deletions Chapter01/recipe-10/cxx-example/animal-farm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ typedef std::function<std::unique_ptr<Animal>(const std::string &)> CreateAnimal
int main() {
Factory<CreateAnimal> farm;
farm.subscribe("CAT",
[](const std::string & n) { return std::make_unique<Cat>(n); });
[](const std::string &n) { return std::make_unique<Cat>(n); });
farm.subscribe("DOG",
[](const std::string & n) { return std::make_unique<Dog>(n); });
[](const std::string &n) { return std::make_unique<Dog>(n); });

std::unique_ptr<Animal> simon = farm.create("CAT", "Simon");
std::unique_ptr<Animal> marlowe = farm.create("DOG", "Marlowe");
Expand Down
2 changes: 1 addition & 1 deletion Chapter03/recipe-03/cxx-example/Py2-pure-embedding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <Python.h>

int main(int argc, char * argv[]) {
int main(int argc, char *argv[]) {
PyObject *pName, *pModule, *pDict, *pFunc;
PyObject *pArgs, *pValue;
int i;
Expand Down
2 changes: 1 addition & 1 deletion Chapter03/recipe-03/cxx-example/Py3-pure-embedding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <Python.h>

int main(int argc, char * argv[]) {
int main(int argc, char *argv[]) {
PyObject *pName, *pModule, *pDict, *pFunc;
PyObject *pArgs, *pValue;
int i;
Expand Down
10 changes: 5 additions & 5 deletions Chapter03/recipe-04/cxx-example/CxxBLAS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
10 changes: 5 additions & 5 deletions Chapter03/recipe-04/cxx-example/CxxBLAS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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);

/*!
Expand All @@ -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);
8 changes: 4 additions & 4 deletions Chapter03/recipe-04/cxx-example/CxxLAPACK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions Chapter03/recipe-04/cxx-example/CxxLAPACK.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
2 changes: 1 addition & 1 deletion Chapter03/recipe-04/cxx-example/linear-algebra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Chapter03/recipe-05/cxx-example/hello-openmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Chapter03/recipe-06/cxx-example/hello-mpi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include <mpi.h>

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.
Expand Down
2 changes: 1 addition & 1 deletion Chapter03/recipe-07/cxx-example/linear-algebra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <Eigen/Dense>

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;
Expand Down
4 changes: 2 additions & 2 deletions Chapter03/recipe-08/cxx-example/path-info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion Chapter04/recipe-01/cxx-example/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> integers;
for (int i = 1; i < argc; i++) {
Expand Down
2 changes: 1 addition & 1 deletion Chapter04/recipe-01/cxx-example/sum_integers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

int sum_integers(const std::vector<int> integers) {
int sum = 0;
for (auto & i : integers) {
for (auto &i : integers) {
sum += i;
}
return sum;
Expand Down
Loading

0 comments on commit 7991e10

Please sign in to comment.