get rid of utils::boundsbig() by making it a template function with two specializations

This commit is contained in:
Axel Kohlmeyer
2020-08-31 11:25:43 -04:00
parent 8d2c16ad66
commit cf11945e21
4 changed files with 10 additions and 35 deletions

View File

@ -878,9 +878,6 @@ Argument processing
.. doxygenfunction:: bounds
:project: progguide
.. doxygenfunction:: boundsbig
:project: progguide
.. doxygenfunction:: expand_args
:project: progguide

View File

@ -633,7 +633,7 @@ void Set::selection(int n)
if (atom->tag_enable == 0)
error->all(FLERR,"Cannot use set atom with no atom IDs defined");
bigint nlobig,nhibig;
utils::boundsbig(FLERR,id,1,MAXTAGINT,nlobig,nhibig,error);
utils::bounds(FLERR,id,1,MAXTAGINT,nlobig,nhibig,error);
tagint *tag = atom->tag;
for (int i = 0; i < n; i++)
@ -644,7 +644,7 @@ void Set::selection(int n)
if (atom->molecule_flag == 0)
error->all(FLERR,"Cannot use set mol with no molecule IDs defined");
bigint nlobig,nhibig;
utils::boundsbig(FLERR,id,1,MAXTAGINT,nlobig,nhibig,error);
utils::bounds(FLERR,id,1,MAXTAGINT,nlobig,nhibig,error);
tagint *molecule = atom->molecule;
for (int i = 0; i < n; i++)

View File

@ -359,8 +359,9 @@ tagint utils::tnumeric(const char *file, int line, const char *str,
/* ----------------------------------------------------------------------
compute bounds implied by numeric str with a possible wildcard asterisk
------------------------------------------------------------------------- */
template<>
void utils::bounds(const char *file, int line, char *str,
int nmin, int nmax, int &nlo, int &nhi, Error *error)
bigint nmin, bigint nmax, int &nlo, int &nhi, Error *error)
{
char *ptr = strchr(str,'*');
@ -398,9 +399,10 @@ void utils::bounds(const char *file, int line, char *str,
/* ----------------------------------------------------------------------
compute bounds implied by numeric str with a possible wildcard asterisk
------------------------------------------------------------------------- */
void utils::boundsbig(const char *file, int line, char *str,
bigint nmin, bigint nmax, bigint &nlo, bigint &nhi,
Error *error)
template <>
void utils::bounds(const char *file, int line, char *str,
bigint nmin, bigint nmax, bigint &nlo, bigint &nhi,
Error *error)
{
char *ptr = strchr(str,'*');

View File

@ -162,33 +162,9 @@ namespace LAMMPS_NS {
* \param nlo lower bound
* \param nhi upper bound
* \param error pointer to Error class for out-of-bounds messages */
template <typename TYPE>
void bounds(const char *file, int line, char *str,
int nmin, int nmax, int &nlo, int &nhi, Error *error);
/** Compute index bounds derived from a string with a possible wildcard
*
* This functions processes the string in *str* and set the values of *nlo*
* and *nhi* according to the following five cases:
*
* - a single number, i: nlo = i; nhi = i;
* - a single asterisk, \*: nlo = nmin; nhi = nmax;
* - a single number followed by an asterisk, i\*: nlo = i; nhi = nmax;
* - a single asterisk followed by a number, \*i: nlo = nmin; nhi = i;
* - two numbers with an asterisk in between. i\*j: nlo = i; nhi = j;
*
* \param file name of source file for error message
* \param line line number in source file for error message
* \param str string to be processed
* \param nmin smallest possible lower bound
* \param nmax largest allowed upper bound
* \param nlo lower bound
* \param nhi upper bound
* \param error pointer to Error class for out-of-bounds messages */
void boundsbig(const char *file, int line, char *str,
bigint nmin, bigint nmax, bigint &nlo, bigint &nhi,
Error *error);
bigint nmin, bigint nmax, TYPE &nlo, TYPE &nhi, Error *error);
/** Expand list of arguments when containing fix/compute wildcards
*