Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
d020438a
Commit
d020438a
authored
May 07, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made get_or_else const
parent
ef3dfadf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
22 deletions
+9
-22
cppa/option.hpp
cppa/option.hpp
+9
-22
No files found.
cppa/option.hpp
View file @
d020438a
...
...
@@ -49,7 +49,7 @@ class option
/**
* @brief Typdef for @p T.
*/
typedef
T
value_
type
;
typedef
T
type
;
/**
* @brief Default constructor.
...
...
@@ -61,13 +61,7 @@ class option
* @brief Creates an @p option from @p value.
* @post <tt>valid() == true</tt>
*/
option
(
T
&&
value
)
:
m_valid
(
false
)
{
cr
(
std
::
move
(
value
));
}
/**
* @brief Creates an @p option from @p value.
* @post <tt>valid() == true</tt>
*/
option
(
T
const
&
value
)
:
m_valid
(
false
)
{
cr
(
value
);
}
option
(
T
value
)
:
m_valid
(
false
)
{
cr
(
std
::
move
(
value
));
}
option
(
option
const
&
other
)
:
m_valid
(
false
)
{
...
...
@@ -129,15 +123,17 @@ class option
*/
inline
bool
valid
()
const
{
return
m_valid
;
}
inline
bool
empty
()
const
{
return
!
m_valid
;
}
/**
* @copydoc valid()
*/
inline
explicit
operator
bool
()
const
{
return
m_valid
;
}
inline
explicit
operator
bool
()
const
{
return
valid
()
;
}
/**
* @brief Returns <tt>!valid()</tt>
*/
inline
bool
operator
!
()
const
{
return
!
m_valid
;
}
inline
bool
operator
!
()
const
{
return
empty
()
;
}
/**
* @brief Returns the value.
...
...
@@ -180,19 +176,10 @@ class option
* if <tt>valid() == false</tt>.
* @post <tt>valid() == true</tt>
*/
inline
T
&
get_or_else
(
T
const
&
default_value
)
inline
const
T
&
get_or_else
(
const
T
&
default_value
)
const
{
if
(
!
m_valid
)
cr
(
default_value
);
return
m_value
;
}
/**
* @copydoc get_or_else(T const&)
*/
inline
T
&
get_or_else
(
T
&&
default_value
)
{
if
(
!
m_valid
)
cr
(
std
::
move
(
default_value
));
return
m_value
;
if
(
valid
())
return
get
();
return
default_value
;
}
private:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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