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
1e3fb346
Commit
1e3fb346
authored
Oct 04, 2012
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
be less restrictive on either's template parameters and added two inspection functions
parent
53a2fca5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
3 deletions
+27
-3
cppa/either.hpp
cppa/either.hpp
+27
-3
No files found.
cppa/either.hpp
View file @
1e3fb346
...
@@ -44,9 +44,9 @@ namespace cppa {
...
@@ -44,9 +44,9 @@ namespace cppa {
template
<
class
Left
,
class
Right
>
template
<
class
Left
,
class
Right
>
class
either
{
class
either
{
static_assert
(
std
::
is_convertible
<
Left
,
Right
>::
value
==
false
//
static_assert( std::is_convertible<Left, Right>::value == false
&&
std
::
is_convertible
<
Right
,
Left
>::
value
==
false
,
//
&& std::is_convertible<Right, Left>::value == false,
"Left is not allowed to be convertible to Right"
);
//
"Left is not allowed to be convertible to Right");
public:
public:
...
@@ -160,6 +160,30 @@ class either {
...
@@ -160,6 +160,30 @@ class either {
return
m_right
;
return
m_right
;
}
}
template
<
typename
F
>
void
apply
(
const
F
&
fun
)
{
if
(
is_left
())
fun
(
left
());
else
fun
(
right
());
}
template
<
typename
F
>
void
apply
(
const
F
&
fun
)
const
{
if
(
is_left
())
fun
(
left
());
else
fun
(
right
());
}
template
<
typename
Result
,
typename
F
>
Result
inspect
(
const
F
&
fun
)
{
if
(
is_left
())
return
fun
(
left
());
else
return
fun
(
right
());
}
template
<
typename
Result
,
typename
F
>
Result
inspect
(
const
F
&
fun
)
const
{
if
(
is_left
())
return
fun
(
left
());
else
return
fun
(
right
());
}
private:
private:
bool
m_is_left
;
bool
m_is_left
;
...
...
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