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
cf96f365
Commit
cf96f365
authored
Aug 21, 2013
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed default-ctor of option & added cppa::none
parent
1fc2e3b2
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
70 additions
and
27 deletions
+70
-27
cppa.files
cppa.files
+1
-0
cppa/detail/opt_impls.hpp
cppa/detail/opt_impls.hpp
+1
-1
cppa/detail/optional_variant_data.hpp
cppa/detail/optional_variant_data.hpp
+2
-2
cppa/detail/tuple_cast_impl.hpp
cppa/detail/tuple_cast_impl.hpp
+3
-3
cppa/guard_expr.hpp
cppa/guard_expr.hpp
+2
-2
cppa/none.hpp
cppa/none.hpp
+42
-0
cppa/optional.hpp
cppa/optional.hpp
+9
-9
cppa/optional_variant.hpp
cppa/optional_variant.hpp
+2
-2
examples/remote_actors/distributed_calculator.cpp
examples/remote_actors/distributed_calculator.cpp
+1
-1
src/broker.cpp
src/broker.cpp
+1
-1
src/default_peer_acceptor.cpp
src/default_peer_acceptor.cpp
+1
-1
src/ipv4_acceptor.cpp
src/ipv4_acceptor.cpp
+1
-1
src/opt.cpp
src/opt.cpp
+1
-1
unit_testing/test_match.cpp
unit_testing/test_match.cpp
+2
-2
unit_testing/test_tuple.cpp
unit_testing/test_tuple.cpp
+1
-1
No files found.
cppa.files
View file @
cf96f365
...
...
@@ -113,6 +113,7 @@ cppa/message_future.hpp
cppa/message_header.hpp
cppa/message_id.hpp
cppa/message_priority.hpp
cppa/none.hpp
cppa/object.hpp
cppa/on.hpp
cppa/opencl.hpp
...
...
cppa/detail/opt_impls.hpp
View file @
cf96f365
...
...
@@ -49,7 +49,7 @@ struct conv_arg_impl {
if
(
iss
>>
result
&&
iss
.
eof
())
{
return
result
;
}
return
{}
;
return
none
;
}
};
...
...
cppa/detail/optional_variant_data.hpp
View file @
cf96f365
...
...
@@ -34,6 +34,8 @@
#include <stdexcept>
#include <type_traits>
#include "cppa/none.hpp"
#define CPPA_OPTIONAL_VARIANT_DATA_CONCAT(x, y) x ## y
#define CPPA_OPTIONAL_VARIANT_DATA_GETTER(pos) \
...
...
@@ -46,8 +48,6 @@
return CPPA_OPTIONAL_VARIANT_DATA_CONCAT(v, pos) ; \
}
namespace
cppa
{
struct
none_t
;
}
namespace
cppa
{
namespace
detail
{
template
<
typename
T
>
...
...
cppa/detail/tuple_cast_impl.hpp
View file @
cf96f365
...
...
@@ -60,7 +60,7 @@ struct tuple_cast_impl {
mapping_vector
mv
;
if
(
matches
<
T
...
>
(
tup
,
mv
))
return
{
Result
::
from
(
std
::
move
(
tup
.
vals
()),
mv
)};
return
{}
;
return
none
;
}
};
...
...
@@ -68,7 +68,7 @@ template<class Result, typename... T>
struct
tuple_cast_impl
<
wildcard_position
::
nil
,
Result
,
T
...
>
{
static
inline
optional
<
Result
>
safe
(
any_tuple
&
tup
)
{
if
(
matches
<
T
...
>
(
tup
))
return
{
Result
::
from
(
std
::
move
(
tup
.
vals
()))};
return
{}
;
return
none
;
}
};
...
...
@@ -82,7 +82,7 @@ struct tuple_cast_impl<wildcard_position::leading, Result, T...> {
static
inline
optional
<
Result
>
safe
(
any_tuple
&
tup
)
{
size_t
o
=
tup
.
size
()
-
(
sizeof
...(
T
)
-
1
);
if
(
matches
<
T
...
>
(
tup
))
return
{
Result
::
offset_subtuple
(
tup
.
vals
(),
o
)};
return
{}
;
return
none
;
}
};
...
...
cppa/guard_expr.hpp
View file @
cf96f365
...
...
@@ -216,7 +216,7 @@ struct ge_get_front {
std
::
reference_wrapper
<
const
typename
util
::
rm_const_and_ref
<
decltype
(
what
.
front
())
>::
type
>
>
{
if
(
what
.
empty
()
==
false
)
return
{
what
.
front
()};
return
{}
;
return
none
;
}
template
<
class
C
>
inline
auto
operator
()(
const
C
&
what
,
...
...
@@ -227,7 +227,7 @@ struct ge_get_front {
>::
type
*
=
0
)
const
->
optional
<
decltype
(
what
.
front
())
>
{
if
(
what
.
empty
()
==
false
)
return
{
what
.
front
()};
return
{}
;
return
none
;
}
};
...
...
cppa/none.hpp
0 → 100644
View file @
cf96f365
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef CPPA_NONE_HPP
#define CPPA_NONE_HPP
namespace
cppa
{
struct
none_t
{
inline
explicit
operator
bool
()
const
{
return
false
;
}
};
static
constexpr
none_t
none
=
none_t
{};
}
// namespace cppa
#endif // CPPA_NONE_HPP
cppa/optional.hpp
View file @
cf96f365
...
...
@@ -33,6 +33,8 @@
#include <new>
#include <utility>
#include "cppa/none.hpp"
#include "cppa/config.hpp"
namespace
cppa
{
...
...
@@ -50,11 +52,16 @@ class optional {
*/
typedef
T
type
;
/**
/*
*
* @brief Default constructor.
* @post <tt>valid() == false</tt>
*/
optional
()
:
m_valid
(
false
)
{
}
//optional() : m_valid(false) { }
/**
* @post <tt>valid() == false</tt>
*/
optional
(
const
none_t
&
)
:
m_valid
(
false
)
{
}
/**
* @brief Creates an @p option from @p value.
...
...
@@ -62,13 +69,6 @@ class optional {
*/
optional
(
T
value
)
:
m_valid
(
false
)
{
cr
(
std
::
move
(
value
));
}
template
<
typename
T0
,
typename
T1
,
typename
...
Ts
>
optional
(
T0
&&
arg0
,
T1
&&
arg1
,
Ts
&&
...
args
)
:
m_valid
(
false
)
{
cr
(
T
(
std
::
forward
<
T0
>
(
arg0
),
std
::
forward
<
T1
>
(
arg1
),
std
::
forward
<
Ts
>
(
args
)...));
}
optional
(
const
optional
&
other
)
:
m_valid
(
false
)
{
if
(
other
.
m_valid
)
cr
(
other
.
m_value
);
}
...
...
cppa/optional_variant.hpp
View file @
cf96f365
...
...
@@ -34,6 +34,8 @@
#include <stdexcept>
#include <type_traits>
#include "cppa/none.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/void_type.hpp"
#include "cppa/util/type_traits.hpp"
...
...
@@ -47,8 +49,6 @@
namespace
cppa
{
struct
none_t
{
};
template
<
int
Value
>
constexpr
std
::
integral_constant
<
int
,
Value
>
make_int_token
()
{
return
{};
}
...
...
examples/remote_actors/distributed_calculator.cpp
View file @
cf96f365
...
...
@@ -144,7 +144,7 @@ void client_repl(const string& host, uint16_t port) {
try
{
return
{
std
::
stoi
(
str
)};
}
catch
(
std
::
exception
&
)
{
aout
<<
"
\"
"
<<
str
<<
"
\"
is not an integer"
<<
endl
;
return
{}
;
return
none
;
}
};
...
...
src/broker.cpp
View file @
cf96f365
...
...
@@ -258,7 +258,7 @@ class broker::doorman : public broker::servant {
continue_reading_result
continue_reading
()
override
{
CPPA_LOG_TRACE
(
""
);
for
(;;)
{
optional
<
stream_ptr_pair
>
opt
;
optional
<
stream_ptr_pair
>
opt
{
none
}
;
try
{
opt
=
m_ptr
->
try_accept_connection
();
}
catch
(
std
::
exception
&
e
)
{
CPPA_LOG_ERROR
(
to_verbose_string
(
e
));
...
...
src/default_peer_acceptor.cpp
View file @
cf96f365
...
...
@@ -53,7 +53,7 @@ default_peer_acceptor::default_peer_acceptor(default_protocol* parent,
continue_reading_result
default_peer_acceptor
::
continue_reading
()
{
CPPA_LOG_TRACE
(
""
);
for
(;;)
{
optional
<
stream_ptr_pair
>
opt
;
optional
<
stream_ptr_pair
>
opt
{
none
}
;
try
{
opt
=
m_ptr
->
try_accept_connection
();
}
catch
(
exception
&
e
)
{
CPPA_LOG_ERROR
(
to_verbose_string
(
e
));
...
...
src/ipv4_acceptor.cpp
View file @
cf96f365
...
...
@@ -171,7 +171,7 @@ optional<stream_ptr_pair> ipv4_acceptor::try_accept_connection() {
if
(
accept_impl
(
result
,
m_fd
,
m_is_nonblocking
))
{
return
result
;
}
return
{}
;
return
none
;
}
}
}
// namespace cppa::detail
src/opt.cpp
View file @
cf96f365
...
...
@@ -58,7 +58,7 @@ detail::opt1_rvalue_builder<true> on_opt1(char short_opt,
else
if
(
equal
(
begin
(
prefix
)
+
1
,
end
(
prefix
),
begin
(
input
)))
{
return
input
.
substr
(
prefix
.
size
()
-
1
);
}
return
{}
;
return
none
;
};
vector
<
string
>
opts
;
opts
.
push_back
(
lhs_str
);
...
...
unit_testing/test_match.cpp
View file @
cf96f365
...
...
@@ -290,7 +290,7 @@ int main() {
if
(
endptr
!=
nullptr
&&
*
endptr
==
'\0'
)
{
return
result
;
}
return
{}
;
return
none
;
};
match
(
"42"
)
(
on
(
toint
)
>>
[
&
](
int
i
)
{
...
...
@@ -432,7 +432,7 @@ int main() {
return
vec
.
back
();
}
}
return
{}
;
return
none
;
};
const
char
*
svec
[]
=
{
"-n"
,
"foo"
,
"--name=bar"
,
"-p"
,
"2"
};
...
...
unit_testing/test_tuple.cpp
View file @
cf96f365
...
...
@@ -72,7 +72,7 @@ optional<int> str2int(const std::string& str) {
if
(
endptr
!=
nullptr
&&
*
endptr
==
'\0'
)
{
return
result
;
}
return
{}
;
return
none
;
}
#define CPPA_CHECK_INVOKED(FunName, Args) \
...
...
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