Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
ac58a1af
Commit
ac58a1af
authored
Sep 28, 2018
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Add affectation by an Array
Check ItemValue is initialized and that the Array has the correct size
parent
1475f720
No related branches found
No related tags found
1 merge request
!11
Feature/mpi
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mesh/ItemValue.hpp
+29
-0
29 additions, 0 deletions
src/mesh/ItemValue.hpp
with
29 additions
and
0 deletions
src/mesh/ItemValue.hpp
+
29
−
0
View file @
ac58a1af
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#define ITEM_VALUE_HPP
#define ITEM_VALUE_HPP
#include
<PastisAssert.hpp>
#include
<PastisAssert.hpp>
#include
<PastisOStream.hpp>
#include
<Array.hpp>
#include
<Array.hpp>
...
@@ -68,6 +69,34 @@ class ItemValue
...
@@ -68,6 +69,34 @@ class ItemValue
return
m_values
.
size
();
return
m_values
.
size
();
}
}
template
<
typename
DataType2
>
PASTIS_INLINE
ItemValue
&
operator
=
(
const
Array
<
DataType2
>&
values
)
{
// ensures that DataType is the same as source DataType2
static_assert
(
std
::
is_same
<
std
::
remove_const_t
<
DataType
>
,
std
::
remove_const_t
<
DataType2
>>
(),
"Cannot assign ItemValue of different type"
);
// ensures that const is not lost through copy
static_assert
(((
std
::
is_const
<
DataType2
>
()
and
std
::
is_const
<
DataType
>
())
or
not
std
::
is_const
<
DataType2
>
()),
"Cannot assign ItemValue of const to ItemValue of non-const"
);
if
(
not
m_is_built
)
{
perr
()
<<
"Cannot assign array of values to a non-built ItemValue
\n
"
;
std
::
exit
(
1
);
}
if
(
m_values
.
size
()
!=
values
.
size
())
{
perr
()
<<
"Cannot assign an array of values of a different size
\n
"
;
std
::
exit
(
1
);
}
m_values
=
values
;
return
*
this
;
}
template
<
typename
DataType2
>
template
<
typename
DataType2
>
PASTIS_INLINE
PASTIS_INLINE
ItemValue
&
ItemValue
&
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment