flag move constructor and swap function as noexcept for improved performance
This commit is contained in:
@ -215,8 +215,8 @@ namespace MathEigen {
|
||||
public:
|
||||
// C++ boilerplate: copy and move constructor, swap, and assignment operator
|
||||
Jacobi(const Jacobi<Scalar, Vector, Matrix, ConstMatrix>& source);
|
||||
Jacobi(Jacobi<Scalar, Vector, Matrix, ConstMatrix>&& other);
|
||||
void swap(Jacobi<Scalar, Vector, Matrix, ConstMatrix> &other);
|
||||
Jacobi(Jacobi<Scalar, Vector, Matrix, ConstMatrix>&& other) noexcept;
|
||||
void swap(Jacobi<Scalar, Vector, Matrix, ConstMatrix> &other) noexcept;
|
||||
Jacobi<Scalar, Vector, Matrix, ConstMatrix>& operator = (Jacobi<Scalar, Vector, Matrix, ConstMatrix> source);
|
||||
|
||||
}; // class Jacobi
|
||||
@ -878,7 +878,7 @@ Jacobi(const Jacobi<Scalar, Vector, Matrix, ConstMatrix>& source)
|
||||
|
||||
template<typename Scalar,typename Vector,typename Matrix,typename ConstMatrix>
|
||||
void Jacobi<Scalar, Vector, Matrix, ConstMatrix>::
|
||||
swap(Jacobi<Scalar, Vector, Matrix, ConstMatrix> &other) {
|
||||
swap(Jacobi<Scalar, Vector, Matrix, ConstMatrix> &other) noexcept {
|
||||
std::swap(n, other.n);
|
||||
std::swap(is_preallocated, other.is_preallocated);
|
||||
std::swap(max_idx_row, other.max_idx_row);
|
||||
@ -888,7 +888,7 @@ swap(Jacobi<Scalar, Vector, Matrix, ConstMatrix> &other) {
|
||||
// Move constructor (C++11)
|
||||
template<typename Scalar,typename Vector,typename Matrix,typename ConstMatrix>
|
||||
Jacobi<Scalar, Vector, Matrix, ConstMatrix>::
|
||||
Jacobi(Jacobi<Scalar, Vector, Matrix, ConstMatrix>&& other) {
|
||||
Jacobi(Jacobi<Scalar, Vector, Matrix, ConstMatrix>&& other) noexcept {
|
||||
Init();
|
||||
this->swap(other);
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ Tokenizer::Tokenizer(const Tokenizer &rhs) :
|
||||
reset();
|
||||
}
|
||||
|
||||
Tokenizer::Tokenizer(Tokenizer &&rhs) :
|
||||
Tokenizer::Tokenizer(Tokenizer &&rhs) noexcept :
|
||||
text(std::move(rhs.text)), separators(std::move(rhs.separators)), ntokens(rhs.ntokens)
|
||||
{
|
||||
reset();
|
||||
@ -78,14 +78,14 @@ Tokenizer &Tokenizer::operator=(const Tokenizer &other)
|
||||
return *this;
|
||||
}
|
||||
|
||||
Tokenizer &Tokenizer::operator=(Tokenizer &&other)
|
||||
Tokenizer &Tokenizer::operator=(Tokenizer &&other) noexcept
|
||||
{
|
||||
Tokenizer tmp(std::move(other));
|
||||
swap(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Tokenizer::swap(Tokenizer &other)
|
||||
void Tokenizer::swap(Tokenizer &other) noexcept
|
||||
{
|
||||
std::swap(text, other.text);
|
||||
std::swap(separators, other.separators);
|
||||
@ -221,7 +221,7 @@ ValueTokenizer::ValueTokenizer(const std::string &str, const std::string &separa
|
||||
{
|
||||
}
|
||||
|
||||
ValueTokenizer::ValueTokenizer(ValueTokenizer &&rhs) : tokens(std::move(rhs.tokens)) {}
|
||||
ValueTokenizer::ValueTokenizer(ValueTokenizer &&rhs) noexcept : tokens(std::move(rhs.tokens)) {}
|
||||
|
||||
ValueTokenizer &ValueTokenizer::operator=(const ValueTokenizer &other)
|
||||
{
|
||||
@ -230,14 +230,14 @@ ValueTokenizer &ValueTokenizer::operator=(const ValueTokenizer &other)
|
||||
return *this;
|
||||
}
|
||||
|
||||
ValueTokenizer &ValueTokenizer::operator=(ValueTokenizer &&other)
|
||||
ValueTokenizer &ValueTokenizer::operator=(ValueTokenizer &&other) noexcept
|
||||
{
|
||||
ValueTokenizer tmp(std::move(other));
|
||||
swap(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void ValueTokenizer::swap(ValueTokenizer &other)
|
||||
void ValueTokenizer::swap(ValueTokenizer &other) noexcept
|
||||
{
|
||||
std::swap(tokens, other.tokens);
|
||||
}
|
||||
|
||||
@ -36,11 +36,11 @@ class Tokenizer {
|
||||
|
||||
public:
|
||||
Tokenizer(std::string str, std::string separators = TOKENIZER_DEFAULT_SEPARATORS);
|
||||
Tokenizer(Tokenizer &&);
|
||||
Tokenizer(Tokenizer &&) noexcept;
|
||||
Tokenizer(const Tokenizer &);
|
||||
Tokenizer &operator=(const Tokenizer &);
|
||||
Tokenizer &operator=(Tokenizer &&);
|
||||
void swap(Tokenizer &);
|
||||
Tokenizer &operator=(Tokenizer &&) noexcept;
|
||||
void swap(Tokenizer &) noexcept;
|
||||
|
||||
void reset();
|
||||
void skip(int n = 1);
|
||||
@ -111,10 +111,10 @@ class ValueTokenizer {
|
||||
ValueTokenizer(const std::string &str,
|
||||
const std::string &separators = TOKENIZER_DEFAULT_SEPARATORS);
|
||||
ValueTokenizer(const ValueTokenizer &) = default;
|
||||
ValueTokenizer(ValueTokenizer &&);
|
||||
ValueTokenizer(ValueTokenizer &&) noexcept;
|
||||
ValueTokenizer &operator=(const ValueTokenizer &);
|
||||
ValueTokenizer &operator=(ValueTokenizer &&);
|
||||
void swap(ValueTokenizer &);
|
||||
ValueTokenizer &operator=(ValueTokenizer &&) noexcept;
|
||||
void swap(ValueTokenizer &) noexcept;
|
||||
|
||||
std::string next_string();
|
||||
tagint next_tagint();
|
||||
|
||||
Reference in New Issue
Block a user