Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
24bdf433
Commit
24bdf433
authored
Nov 08, 2019
by
Nick Draper
Browse files
Change push_back to emplace_back where possible
re #27319
parent
0993721b
Changes
755
Hide whitespace changes
Inline
Side-by-side
Framework/API/inc/MantidAPI/Algorithm.tcc
View file @
24bdf433
...
...
@@ -69,9 +69,9 @@ void Algorithm::declareWorkspaceInputProperties(const std::string &propertyName,
"index type; Indices are entered as a comma-separated list "
"of values, and/or ranges; For example, '4,6,10-20,1000';");
m_reservedList.
push
_back(propertyName);
m_reservedList.
push
_back(indexTypePropName);
m_reservedList.
push
_back(indexPropName);
m_reservedList.
emplace
_back(propertyName);
m_reservedList.
emplace
_back(indexTypePropName);
m_reservedList.
emplace
_back(indexPropName);
}
template <typename T1, typename T2, typename WsType>
...
...
Framework/API/inc/MantidAPI/WorkspaceProperty.tcc
View file @
24bdf433
...
...
@@ -327,7 +327,7 @@ std::vector<std::string> WorkspaceProperty<TYPE>::allowedValues() const {
Mantid::Kernel::DataServiceSort::Sorted);
if (isOptional()) // Insert an empty option
{
vals.
push
_back("");
vals.
emplace
_back("");
}
// Copy-construct a temporary workspace property to test the validity of
// each workspace
...
...
Framework/API/src/ADSValidator.cpp
View file @
24bdf433
...
...
@@ -74,7 +74,7 @@ std::vector<std::string> ADSValidator::allowedValues() const {
Mantid
::
Kernel
::
DataServiceSort
::
Sorted
);
if
(
isOptional
())
// Insert an empty option
{
vals
.
push
_back
(
""
);
vals
.
emplace
_back
(
""
);
}
return
vals
;
}
...
...
Framework/API/src/Algorithm.cpp
View file @
24bdf433
...
...
@@ -321,15 +321,15 @@ void Algorithm::cacheWorkspaceProperties() {
continue
;
switch
(
prop
->
direction
())
{
case
Kernel
::
Direction
::
Input
:
m_inputWorkspaceProps
.
push
_back
(
wsProp
);
m_inputWorkspaceProps
.
emplace
_back
(
wsProp
);
break
;
case
Kernel
::
Direction
::
InOut
:
m_inputWorkspaceProps
.
push
_back
(
wsProp
);
m_outputWorkspaceProps
.
push
_back
(
wsProp
);
m_inputWorkspaceProps
.
emplace
_back
(
wsProp
);
m_outputWorkspaceProps
.
emplace
_back
(
wsProp
);
break
;
case
Kernel
::
Direction
::
Output
:
m_outputWorkspaceProps
.
push
_back
(
wsProp
);
m_pureOutputWorkspaceProps
.
push
_back
(
wsProp
);
m_outputWorkspaceProps
.
emplace
_back
(
wsProp
);
m_pureOutputWorkspaceProps
.
emplace
_back
(
wsProp
);
break
;
default:
throw
std
::
logic_error
(
...
...
@@ -433,7 +433,7 @@ void Algorithm::lockWorkspaces() {
// Write-lock it if not already
debugLog
<<
"Write-locking "
<<
ws
->
getName
()
<<
'\n'
;
ws
->
getLock
()
->
writeLock
();
m_writeLockedWorkspaces
.
push
_back
(
ws
);
m_writeLockedWorkspaces
.
emplace
_back
(
ws
);
}
}
}
...
...
@@ -451,7 +451,7 @@ void Algorithm::lockWorkspaces() {
// Read-lock it if not already write-locked
debugLog
<<
"Read-locking "
<<
ws
->
getName
()
<<
'\n'
;
ws
->
getLock
()
->
readLock
();
m_readLockedWorkspaces
.
push
_back
(
ws
);
m_readLockedWorkspaces
.
emplace
_back
(
ws
);
}
}
}
...
...
@@ -773,7 +773,7 @@ void Algorithm::store() {
throw
;
}
}
else
{
groupWsIndicies
.
push
_back
(
i
);
groupWsIndicies
.
emplace
_back
(
i
);
}
}
}
...
...
@@ -870,7 +870,7 @@ void Algorithm::setupAsChildAlgorithm(Algorithm_sptr alg,
// in parallel safely.
boost
::
weak_ptr
<
IAlgorithm
>
weakPtr
(
alg
);
PARALLEL_CRITICAL
(
Algorithm_StoreWeakPtr
)
{
m_ChildAlgorithms
.
push
_back
(
weakPtr
);
m_ChildAlgorithms
.
emplace
_back
(
weakPtr
);
}
}
...
...
@@ -1390,7 +1390,7 @@ bool Algorithm::processGroups() {
auto
*
prop
=
dynamic_cast
<
Property
*>
(
pureOutputWorkspaceProp
);
if
(
prop
&&
!
prop
->
value
().
empty
())
{
auto
outWSGrp
=
boost
::
make_shared
<
WorkspaceGroup
>
();
outGroups
.
push
_back
(
outWSGrp
);
outGroups
.
emplace
_back
(
outWSGrp
);
// Put the GROUP in the ADS
AnalysisDataService
::
Instance
().
addOrReplace
(
prop
->
value
(),
outWSGrp
);
outWSGrp
->
observeADSNotifications
(
false
);
...
...
Framework/API/src/AlgorithmFactory.cpp
View file @
24bdf433
...
...
@@ -216,7 +216,7 @@ AlgorithmFactoryImpl::getKeys(bool includeHidden) const {
if
(
!
toBeRemoved
)
{
// just mark them to be removed as we are iterating around the vector at
// the moment
validNames
.
push
_back
(
name
);
validNames
.
emplace
_back
(
name
);
}
}
return
validNames
;
...
...
@@ -383,7 +383,7 @@ AlgorithmFactoryImpl::getDescriptors(bool includeHidden) const {
}
if
(
!
categoryIsHidden
)
res
.
push
_back
(
desc
);
res
.
emplace
_back
(
desc
);
}
}
return
res
;
...
...
Framework/API/src/AlgorithmHistory.cpp
View file @
24bdf433
...
...
@@ -91,7 +91,7 @@ void AlgorithmHistory::setProperties(const Algorithm *const alg) {
// objects.
const
std
::
vector
<
Property
*>
&
properties
=
alg
->
getProperties
();
for
(
const
auto
&
property
:
properties
)
{
m_properties
.
push
_back
(
m_properties
.
emplace
_back
(
boost
::
make_shared
<
PropertyHistory
>
(
property
->
createHistory
()));
}
}
...
...
@@ -147,7 +147,7 @@ void AlgorithmHistory::addExecutionInfo(const DateAndTime &start,
void
AlgorithmHistory
::
addProperty
(
const
std
::
string
&
name
,
const
std
::
string
&
value
,
bool
isdefault
,
const
unsigned
int
&
direction
)
{
m_properties
.
push
_back
(
boost
::
make_shared
<
PropertyHistory
>
(
m_properties
.
emplace
_back
(
boost
::
make_shared
<
PropertyHistory
>
(
name
,
value
,
""
,
isdefault
,
direction
));
}
...
...
Framework/API/src/AlgorithmManager.cpp
View file @
24bdf433
...
...
@@ -112,7 +112,7 @@ IAlgorithm_sptr AlgorithmManagerImpl::create(const std::string &algName,
}
// Add to list of managed ones
m_managed_algs
.
push
_back
(
alg
);
m_managed_algs
.
emplace
_back
(
alg
);
alg
->
initialize
();
}
catch
(
std
::
runtime_error
&
ex
)
{
...
...
Framework/API/src/AlgorithmProxy.cpp
View file @
24bdf433
...
...
@@ -144,7 +144,7 @@ void AlgorithmProxy::addObserver(const Poco::AbstractObserver &observer) const {
}
// save the observer in any case because m_alg can be reset (eg in
// createConcreteAlg())
m_externalObservers
.
push
_back
(
obs
);
m_externalObservers
.
emplace
_back
(
obs
);
}
/** Remove an observer.
...
...
Framework/API/src/CompositeCatalog.cpp
View file @
24bdf433
...
...
@@ -17,7 +17,7 @@ CompositeCatalog::CompositeCatalog() : m_catalogs() {}
* @param catalog :: The catalog to add to the container.
*/
void
CompositeCatalog
::
add
(
const
ICatalog_sptr
catalog
)
{
m_catalogs
.
push
_back
(
catalog
);
m_catalogs
.
emplace
_back
(
catalog
);
}
/**
...
...
Framework/API/src/CompositeFunction.cpp
View file @
24bdf433
...
...
@@ -403,13 +403,13 @@ void CompositeFunction::clear() {
*/
size_t
CompositeFunction
::
addFunction
(
IFunction_sptr
f
)
{
m_IFunction
.
insert
(
m_IFunction
.
end
(),
f
->
nParams
(),
m_functions
.
size
());
m_functions
.
push
_back
(
f
);
m_functions
.
emplace
_back
(
f
);
//?f->init();
if
(
m_paramOffsets
.
empty
())
{
m_paramOffsets
.
push
_back
(
0
);
m_paramOffsets
.
emplace
_back
(
0
);
m_nParams
=
f
->
nParams
();
}
else
{
m_paramOffsets
.
push
_back
(
m_nParams
);
m_paramOffsets
.
emplace
_back
(
m_nParams
);
m_nParams
+=
f
->
nParams
();
}
return
m_functions
.
size
()
-
1
;
...
...
@@ -828,14 +828,14 @@ CompositeFunction::createEquivalentFunctions() const {
std
::
vector
<
std
::
vector
<
IFunction_sptr
>>
equiv
;
equiv
.
reserve
(
nf
);
for
(
size_t
i
=
0
;
i
<
nf
;
++
i
)
{
equiv
.
push
_back
(
getFunction
(
i
)
->
createEquivalentFunctions
());
equiv
.
emplace
_back
(
getFunction
(
i
)
->
createEquivalentFunctions
());
}
std
::
vector
<
IFunction_sptr
>
funs
;
funs
.
reserve
(
nd
);
for
(
size_t
i
=
0
;
i
<
nd
;
++
i
)
{
auto
comp
=
new
CompositeFunction
;
funs
.
push
_back
(
IFunction_sptr
(
comp
));
funs
.
emplace
_back
(
IFunction_sptr
(
comp
));
for
(
size_t
j
=
0
;
j
<
nf
;
++
j
)
{
comp
->
addFunction
(
equiv
[
j
][
i
]);
}
...
...
Framework/API/src/DetectorSearcher.cpp
View file @
24bdf433
...
...
@@ -86,8 +86,8 @@ void DetectorSearcher::createDetectorCache() {
if
(
point
.
hasNaN
()
||
up
.
coLinear
(
beam
,
pos
))
continue
;
points
.
push
_back
(
point
);
m_indexMap
.
push
_back
(
pointNo
);
points
.
emplace
_back
(
point
);
m_indexMap
.
emplace
_back
(
pointNo
);
}
// create KDtree of cached detector Q vectors
...
...
Framework/API/src/Expression.cpp
View file @
24bdf433
...
...
@@ -205,7 +205,7 @@ void Expression::parse(const std::string &str) {
setFunct
(
*
tkz
.
begin
());
for
(
size_t
i
=
0
;
i
<=
m_tokens
.
size
();
i
++
)
{
m_terms
.
push
_back
(
Expression
(
this
));
m_terms
.
emplace
_back
(
Expression
(
this
));
Expression
&
t
=
m_terms
.
back
();
if
(
i
)
t
.
m_op
=
GetOp
(
i
-
1
);
...
...
@@ -330,7 +330,7 @@ void Expression::tokenize() {
if
(
prec
<
min_prec
)
min_prec
=
prec
;
Token
tok
(
is
,
i
-
1
,
is1
,
prec
);
tokens
.
push
_back
(
tok
);
tokens
.
emplace
_back
(
tok
);
is
=
is1
;
}
...
...
@@ -429,7 +429,7 @@ void Expression::setFunct(const std::string &name) {
m_funct
=
op
;
Expression
tmp
(
this
);
tmp
.
parse
(
name
.
substr
(
op
.
size
()));
m_terms
.
push
_back
(
tmp
);
m_terms
.
emplace
_back
(
tmp
);
return
;
}
}
...
...
@@ -473,7 +473,7 @@ void Expression::setFunct(const std::string &name) {
tmp
.
parse
(
args
);
if
(
tmp
.
name
()
!=
EMPTY_EXPRESSION_NAME
&&
(
!
tmp
.
isFunct
()
||
tmp
.
name
()
!=
","
))
{
m_terms
.
push
_back
(
tmp
);
m_terms
.
emplace
_back
(
tmp
);
}
else
{
if
(
f
.
empty
()
&&
tmp
.
name
()
==
","
)
{
f
=
","
;
...
...
Framework/API/src/FileFinder.cpp
View file @
24bdf433
...
...
@@ -392,7 +392,7 @@ FileFinderImpl::getArchiveSearch(const Kernel::FacilityInfo &facility) const {
for
(
const
auto
&
facilityname
:
facility
.
archiveSearch
())
{
g_log
.
debug
()
<<
"get archive search for the facility..."
<<
facilityname
<<
"
\n
"
;
archs
.
push
_back
(
ArchiveSearchFactory
::
Instance
().
create
(
facilityname
));
archs
.
emplace
_back
(
ArchiveSearchFactory
::
Instance
().
create
(
facilityname
));
}
}
return
archs
;
...
...
@@ -485,7 +485,7 @@ std::string FileFinderImpl::findRun(const std::string &hintstr,
std
::
vector
<
std
::
string
>
uniqueExts
;
uniqueExts
.
reserve
(
1
+
exts
.
size
()
+
extensions
.
size
());
if
(
!
extension
.
empty
())
uniqueExts
.
push
_back
(
extension
);
uniqueExts
.
emplace
_back
(
extension
);
// If provided exts are empty, or useExtsOnly is false,
// we want to include facility exts as well
...
...
@@ -530,7 +530,7 @@ void FileFinderImpl::getUniqueExtensions(
const
auto
searchItr
=
std
::
find
(
uniqueExts
.
begin
(),
uniqueExts
.
end
(),
transformed
);
if
(
searchItr
==
uniqueExts
.
end
())
{
uniqueExts
.
push
_back
(
transformed
);
uniqueExts
.
emplace
_back
(
transformed
);
}
}
}
...
...
@@ -613,7 +613,7 @@ FileFinderImpl::findRuns(const std::string &hintstr,
run
.
insert
(
0
,
"0"
);
std
::
string
path
=
findRun
(
p1
.
first
+
run
,
exts
,
useExtsOnly
);
if
(
!
path
.
empty
())
{
res
.
push
_back
(
path
);
res
.
emplace
_back
(
path
);
}
else
{
throw
Kernel
::
Exception
::
NotFoundError
(
"Unable to find file:"
,
run
);
}
...
...
@@ -621,7 +621,7 @@ FileFinderImpl::findRuns(const std::string &hintstr,
}
else
{
std
::
string
path
=
findRun
(
*
h
,
exts
,
useExtsOnly
);
if
(
!
path
.
empty
())
{
res
.
push
_back
(
path
);
res
.
emplace
_back
(
path
);
}
else
{
throw
Kernel
::
Exception
::
NotFoundError
(
"Unable to find file:"
,
*
h
);
}
...
...
Framework/API/src/FileProperty.cpp
View file @
24bdf433
...
...
@@ -59,7 +59,7 @@ void addExtension(const std::string &extension,
extensions
.
end
())
return
;
else
extensions
.
push
_back
(
extension
);
extensions
.
emplace
_back
(
extension
);
}
/**
...
...
Framework/API/src/FunctionDomainGeneral.cpp
View file @
24bdf433
...
...
@@ -32,7 +32,7 @@ void FunctionDomainGeneral::addColumn(boost::shared_ptr<Column> column) {
"All columns must have the same size."
);
}
m_columns
.
push
_back
(
column
);
m_columns
.
emplace
_back
(
column
);
}
/// Get i-th column.
...
...
Framework/API/src/FunctionFactory.cpp
View file @
24bdf433
...
...
@@ -365,9 +365,9 @@ void FunctionFactoryImpl::addTie(IFunction_sptr fun,
std
::
vector
<
std
::
string
>
FunctionFactoryImpl
::
getFunctionNamesGUI
()
const
{
auto
allNames
=
getFunctionNames
<
IFunction1D
>
();
allNames
.
push
_back
(
"ProductFunction"
);
allNames
.
push
_back
(
"CompositeFunction"
);
allNames
.
push
_back
(
"Convolution"
);
allNames
.
emplace
_back
(
"ProductFunction"
);
allNames
.
emplace
_back
(
"CompositeFunction"
);
allNames
.
emplace
_back
(
"Convolution"
);
std
::
sort
(
allNames
.
begin
(),
allNames
.
end
());
std
::
vector
<
std
::
string
>
names
;
names
.
reserve
(
allNames
.
size
());
...
...
Framework/API/src/GroupingLoader.cpp
View file @
24bdf433
...
...
@@ -239,7 +239,7 @@ boost::shared_ptr<Grouping> GroupingLoader::getDummyGrouping() {
auto
dummyGrouping
=
boost
::
make_shared
<
Mantid
::
API
::
Grouping
>
();
dummyGrouping
->
description
=
"Dummy grouping"
;
dummyGrouping
->
groupNames
.
emplace_back
(
"all"
);
dummyGrouping
->
groups
.
push
_back
(
all
.
str
());
dummyGrouping
->
groups
.
emplace
_back
(
all
.
str
());
return
dummyGrouping
;
}
...
...
@@ -258,14 +258,14 @@ Grouping::Grouping(ITableWorkspace_sptr table) {
// Convert to a range string, i.e. 1-5,6-8,9
std
::
string
detectorRange
=
Kernel
::
Strings
::
toString
(
detectors
);
this
->
groupNames
.
push
_back
(
std
::
to_string
(
row
+
1
));
this
->
groups
.
push
_back
(
detectorRange
);
this
->
groupNames
.
emplace
_back
(
std
::
to_string
(
row
+
1
));
this
->
groups
.
emplace
_back
(
detectorRange
);
}
// If we have 2 groups only - create a longitudinal pair
if
(
this
->
groups
.
size
()
==
2
)
{
this
->
pairNames
.
emplace_back
(
"long"
);
this
->
pairAlphas
.
push
_back
(
1.0
);
this
->
pairAlphas
.
emplace
_back
(
1.0
);
this
->
pairs
.
emplace_back
(
0
,
1
);
}
}
...
...
Framework/API/src/IFunction.cpp
View file @
24bdf433
...
...
@@ -266,7 +266,7 @@ void IFunction::addTie(std::unique_ptr<ParameterTie> tie) {
}
}
if
(
!
found
)
{
m_ties
.
push
_back
(
std
::
move
(
tie
));
m_ties
.
emplace
_back
(
std
::
move
(
tie
));
setParameterStatus
(
iPar
,
Tied
);
}
}
...
...
@@ -368,7 +368,7 @@ void IFunction::addConstraint(std::unique_ptr<IConstraint> ic) {
}
}
if
(
!
found
)
{
m_constraints
.
push
_back
(
std
::
move
(
ic
));
m_constraints
.
emplace
_back
(
std
::
move
(
ic
));
}
}
...
...
@@ -478,7 +478,7 @@ IFunction::writeToString(const std::string &parentLocalAttributesStr) const {
ostr
<<
','
<<
paramOut
.
str
();
// Output non-default ties only.
if
(
getParameterStatus
(
i
)
==
Fixed
)
{
ties
.
push
_back
(
paramOut
.
str
());
ties
.
emplace
_back
(
paramOut
.
str
());
}
}
...
...
@@ -492,7 +492,7 @@ IFunction::writeToString(const std::string &parentLocalAttributesStr) const {
// collect the non-default ties
auto
tiesString
=
writeTies
();
if
(
!
tiesString
.
empty
())
{
ties
.
push
_back
(
tiesString
);
ties
.
emplace
_back
(
tiesString
);
}
// print the ties
if
(
!
ties
.
empty
())
{
...
...
@@ -549,7 +549,7 @@ void IFunction::addConstraints(const std::string &str, bool isDefault) {
std
::
vector
<
std
::
string
>
IFunction
::
getParameterNames
()
const
{
std
::
vector
<
std
::
string
>
out
;
for
(
size_t
i
=
0
;
i
<
nParams
();
++
i
)
{
out
.
push
_back
(
parameterName
(
i
));
out
.
emplace
_back
(
parameterName
(
i
));
}
return
out
;
}
...
...
@@ -1583,7 +1583,7 @@ void IFunction::sortTies() {
}
orderedTieNodes
.
push_front
(
newNode
);
}
else
{
orderedTieNodes
.
push
_back
(
newNode
);
orderedTieNodes
.
emplace
_back
(
newNode
);
}
}
for
(
auto
&&
node
:
orderedTieNodes
)
{
...
...
Framework/API/src/IMDWorkspace.cpp
View file @
24bdf433
...
...
@@ -135,9 +135,9 @@ const std::string IMDWorkspace::toString() const {
void
IMDWorkspace
::
makeSinglePointWithNaN
(
std
::
vector
<
coord_t
>
&
x
,
std
::
vector
<
signal_t
>
&
y
,
std
::
vector
<
signal_t
>
&
e
)
const
{
x
.
push
_back
(
0
);
y
.
push
_back
(
std
::
numeric_limits
<
signal_t
>::
quiet_NaN
());
e
.
push
_back
(
std
::
numeric_limits
<
signal_t
>::
quiet_NaN
());
x
.
emplace
_back
(
0
);
y
.
emplace
_back
(
std
::
numeric_limits
<
signal_t
>::
quiet_NaN
());
e
.
emplace
_back
(
std
::
numeric_limits
<
signal_t
>::
quiet_NaN
());
}
//-----------------------------------------------------------------------------------------------
...
...
@@ -170,14 +170,14 @@ IMDWorkspace::getLinePlot(const Mantid::Kernel::VMD &start,
// Coordinate along the line
VMD
coord
=
start
+
step
*
double
(
i
);
// Record the position along the line
line
.
x
.
push
_back
(
static_cast
<
coord_t
>
(
stepLength
*
double
(
i
)));
line
.
x
.
emplace
_back
(
static_cast
<
coord_t
>
(
stepLength
*
double
(
i
)));
signal_t
yVal
=
this
->
getSignalAtCoord
(
coord
.
getBareArray
(),
normalize
);
line
.
y
.
push
_back
(
yVal
);
line
.
e
.
push
_back
(
0.0
);
line
.
y
.
emplace
_back
(
yVal
);
line
.
e
.
emplace
_back
(
0.0
);
}
// And the last point
line
.
x
.
push
_back
((
end
-
start
).
norm
());
line
.
x
.
emplace
_back
((
end
-
start
).
norm
());
return
line
;
}
...
...
Framework/API/src/IndexTypeProperty.cpp
View file @
24bdf433
...
...
@@ -12,9 +12,9 @@ IndexTypeProperty::IndexTypeProperty(const std::string &name,
const
int
indexType
)
:
PropertyWithValue
<
std
::
string
>
(
name
,
""
,
Kernel
::
Direction
::
Input
)
{
if
(
indexType
&
IndexType
::
WorkspaceIndex
)
m_allowedValues
.
push
_back
(
"WorkspaceIndex"
);
m_allowedValues
.
emplace
_back
(
"WorkspaceIndex"
);
if
(
indexType
&
IndexType
::
SpectrumNum
)
m_allowedValues
.
push
_back
(
"SpectrumNumber"
);
m_allowedValues
.
emplace
_back
(
"SpectrumNumber"
);
if
(
m_allowedValues
.
empty
())
throw
std
::
invalid_argument
(
"Argument indexType incorrectly specified"
);
...
...
Prev
1
2
3
4
5
…
38
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment