use call-by-value with std::move() function
This commit is contained in:
@ -22,6 +22,7 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
@ -68,8 +69,8 @@ This function is useful in combination with :cpp:func:`utils::open_potential`.
|
|||||||
* \param fp File descriptor of the already opened file
|
* \param fp File descriptor of the already opened file
|
||||||
* \param filetype Description of file type for error messages */
|
* \param filetype Description of file type for error messages */
|
||||||
|
|
||||||
TextFileReader::TextFileReader(FILE *fp, const std::string &filetype) :
|
TextFileReader::TextFileReader(FILE *fp, std::string filetype) :
|
||||||
filetype(filetype), closefp(false), fp(fp), ignore_comments(true)
|
filetype(std::move(filetype)), closefp(false), fp(fp), ignore_comments(true)
|
||||||
{
|
{
|
||||||
if (fp == nullptr) throw FileReaderException("Invalid file descriptor");
|
if (fp == nullptr) throw FileReaderException("Invalid file descriptor");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,7 @@ class TextFileReader {
|
|||||||
bool ignore_comments; //!< Controls whether comments are ignored
|
bool ignore_comments; //!< Controls whether comments are ignored
|
||||||
|
|
||||||
TextFileReader(const std::string &filename, const std::string &filetype);
|
TextFileReader(const std::string &filename, const std::string &filetype);
|
||||||
TextFileReader(FILE *fp, const std::string &filetype);
|
TextFileReader(FILE *fp, std::string filetype);
|
||||||
|
|
||||||
~TextFileReader();
|
~TextFileReader();
|
||||||
|
|
||||||
|
|||||||
@ -49,8 +49,8 @@ TokenizerException::TokenizerException(const std::string &msg, const std::string
|
|||||||
* \param str string to be processed
|
* \param str string to be processed
|
||||||
* \param _separators string with separator characters (default: " \t\r\n\f") */
|
* \param _separators string with separator characters (default: " \t\r\n\f") */
|
||||||
|
|
||||||
Tokenizer::Tokenizer(const std::string &str, const std::string &_separators) :
|
Tokenizer::Tokenizer(std::string str, std::string _separators) :
|
||||||
text(str), separators(_separators), start(0), ntokens(std::string::npos)
|
text(std::move(str)), separators(std::move(_separators)), start(0), ntokens(std::string::npos)
|
||||||
{
|
{
|
||||||
// replace known UTF-8 characters with ASCII equivalents
|
// replace known UTF-8 characters with ASCII equivalents
|
||||||
if (utils::has_utf8(text)) text = utils::utf8_subst(text);
|
if (utils::has_utf8(text)) text = utils::utf8_subst(text);
|
||||||
|
|||||||
@ -35,7 +35,7 @@ class Tokenizer {
|
|||||||
size_t ntokens;
|
size_t ntokens;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Tokenizer(const std::string &str, const std::string &separators = TOKENIZER_DEFAULT_SEPARATORS);
|
Tokenizer(std::string str, std::string separators = TOKENIZER_DEFAULT_SEPARATORS);
|
||||||
Tokenizer(Tokenizer &&);
|
Tokenizer(Tokenizer &&);
|
||||||
Tokenizer(const Tokenizer &);
|
Tokenizer(const Tokenizer &);
|
||||||
Tokenizer &operator=(const Tokenizer &);
|
Tokenizer &operator=(const Tokenizer &);
|
||||||
|
|||||||
Reference in New Issue
Block a user