use initializer list instead of explicit constructor

This commit is contained in:
Axel Kohlmeyer
2021-10-14 01:12:44 -04:00
parent 27145d2789
commit e56cc9be00
4 changed files with 7 additions and 7 deletions

View File

@ -1011,7 +1011,7 @@ std::vector<std::string> Info::get_available_styles(const std::string &category)
} else if (category == "command") { } else if (category == "command") {
return get_style_names(input->command_map); return get_style_names(input->command_map);
} }
return std::vector<std::string>(); return {};
} }
template<typename ValueType> template<typename ValueType>

View File

@ -2035,7 +2035,7 @@ std::string Molecule::parse_keyword(int flag, char *line)
MPI_Bcast(&eof,1,MPI_INT,0,world); MPI_Bcast(&eof,1,MPI_INT,0,world);
if (eof) { if (eof) {
return std::string(""); return {""};
} }
// bcast keyword line to all procs // bcast keyword line to all procs

View File

@ -415,7 +415,7 @@ std::string platform::mpi_info(int &major, int &minor)
major = 1; major = 1;
minor = 0; minor = 0;
#endif #endif
return std::string(version); return {version};
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -543,8 +543,8 @@ void *platform::dlopen(const std::string &fname)
std::string platform::dlerror() std::string platform::dlerror()
{ {
const char *errmesg = ::dlerror(); const char *errmesg = ::dlerror();
if (errmesg) return std::string(errmesg); if (errmesg) return {errmesg};
else return ""; else return {""};
} }
// close a shared object // close a shared object

View File

@ -143,7 +143,7 @@ void utils::fmtargs_logmesg(LAMMPS *lmp, fmt::string_view format, fmt::format_ar
std::string utils::getsyserror() std::string utils::getsyserror()
{ {
return std::string(strerror(errno)); return {strerror(errno)};
} }
// read line into buffer. if line is too long keep reading until EOL or EOF // read line into buffer. if line is too long keep reading until EOL or EOF
@ -738,7 +738,7 @@ std::string utils::trim_comment(const std::string &line)
{ {
auto end = line.find_first_of('#'); auto end = line.find_first_of('#');
if (end != std::string::npos) { return line.substr(0, end); } if (end != std::string::npos) { return line.substr(0, end); }
return std::string(line); return {line};
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------