Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102462658
SafeScalar.h
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Feb 21, 00:02
Size
605 B
Mime Type
text/x-c++
Expires
Sun, Feb 23, 00:02 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
24324646
Attached To
rDLMA Diffusion limited mixed aggregation
SafeScalar.h
View Options
// A Scalar that asserts for uninitialized access.
template
<
typename
T
>
class
SafeScalar
{
public:
SafeScalar
()
:
initialized_
(
false
)
{}
SafeScalar
(
const
SafeScalar
&
other
)
{
*
this
=
other
;
}
SafeScalar
&
operator
=
(
const
SafeScalar
&
other
)
{
val_
=
T
(
other
);
initialized_
=
true
;
return
*
this
;
}
SafeScalar
(
T
val
)
:
val_
(
val
),
initialized_
(
true
)
{}
SafeScalar
&
operator
=
(
T
val
)
{
val_
=
val
;
initialized_
=
true
;
}
operator
T
()
const
{
VERIFY
(
initialized_
&&
"Uninitialized access."
);
return
val_
;
}
private:
T
val_
;
bool
initialized_
;
};
Event Timeline
Log In to Comment