Commit 1fc2e3b2 authored by Dominik Charousset's avatar Dominik Charousset

option => optional

this patch renames `optional` to `optional` in advance of porting
libcppa to boost
parent 60429ff3
...@@ -124,7 +124,7 @@ cppa/opencl/opencl_metainfo.hpp ...@@ -124,7 +124,7 @@ cppa/opencl/opencl_metainfo.hpp
cppa/opencl/program.hpp cppa/opencl/program.hpp
cppa/opencl/smart_ptr.hpp cppa/opencl/smart_ptr.hpp
cppa/opt.hpp cppa/opt.hpp
cppa/option.hpp cppa/optional.hpp
cppa/optional_variant.hpp cppa/optional_variant.hpp
cppa/partial_function.hpp cppa/partial_function.hpp
cppa/primitive_type.hpp cppa/primitive_type.hpp
......
...@@ -56,7 +56,7 @@ enum primitive_type : unsigned char; ...@@ -56,7 +56,7 @@ enum primitive_type : unsigned char;
enum class atom_value : std::uint64_t; enum class atom_value : std::uint64_t;
// class templates // class templates
template<typename> class option; template<typename> class optional;
template<typename> class intrusive_ptr; template<typename> class intrusive_ptr;
// typedefs // typedefs
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include <utility> #include <utility>
#include <algorithm> #include <algorithm>
#include "cppa/option.hpp" #include "cppa/optional.hpp"
#include "cppa/config.hpp" #include "cppa/config.hpp"
#include "cppa/behavior.hpp" #include "cppa/behavior.hpp"
#include "cppa/message_id.hpp" #include "cppa/message_id.hpp"
...@@ -61,7 +61,7 @@ class behavior_stack ...@@ -61,7 +61,7 @@ class behavior_stack
behavior_stack() = default; behavior_stack() = default;
// @pre expected_response.valid() // @pre expected_response.valid()
option<behavior&> sync_handler(message_id expected_response); optional<behavior&> sync_handler(message_id expected_response);
// erases the last asynchronous message handler // erases the last asynchronous message handler
void pop_async_back(); void pop_async_back();
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <sstream> #include <sstream>
#include "cppa/on.hpp" #include "cppa/on.hpp"
#include "cppa/option.hpp" #include "cppa/optional.hpp"
// this header contains implementation details for opt.hpp // this header contains implementation details for opt.hpp
...@@ -42,7 +42,7 @@ namespace cppa { namespace detail { ...@@ -42,7 +42,7 @@ namespace cppa { namespace detail {
template<typename T> template<typename T>
struct conv_arg_impl { struct conv_arg_impl {
typedef option<T> result_type; typedef optional<T> result_type;
static inline result_type _(const std::string& arg) { static inline result_type _(const std::string& arg) {
std::istringstream iss(arg); std::istringstream iss(arg);
T result; T result;
...@@ -55,7 +55,7 @@ struct conv_arg_impl { ...@@ -55,7 +55,7 @@ struct conv_arg_impl {
template<> template<>
struct conv_arg_impl<std::string> { struct conv_arg_impl<std::string> {
typedef option<std::string> result_type; typedef optional<std::string> result_type;
static inline result_type _(const std::string& arg) { return arg; } static inline result_type _(const std::string& arg) { return arg; }
}; };
...@@ -165,7 +165,7 @@ class opt1_rvalue_builder { ...@@ -165,7 +165,7 @@ class opt1_rvalue_builder {
.when(cppa::placeholders::_x1.in(std::vector<std::string>()))) .when(cppa::placeholders::_x1.in(std::vector<std::string>())))
left_type; left_type;
typedef decltype(on(std::function<option<std::string>(const std::string&)>())) typedef decltype(on(std::function<optional<std::string>(const std::string&)>()))
right_type; right_type;
template<typename Left, typename Right> template<typename Left, typename Right>
...@@ -203,7 +203,7 @@ class opt1_rvalue_builder<false> { ...@@ -203,7 +203,7 @@ class opt1_rvalue_builder<false> {
public: public:
typedef decltype(on(std::function<option<std::string>(const std::string&)>())) typedef decltype(on(std::function<optional<std::string>(const std::string&)>()))
sub_type; sub_type;
template<typename SubType> template<typename SubType>
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#ifndef CPPA_PROJECTION_HPP #ifndef CPPA_PROJECTION_HPP
#define CPPA_PROJECTION_HPP #define CPPA_PROJECTION_HPP
#include "cppa/option.hpp" #include "cppa/optional.hpp"
#include "cppa/guard_expr.hpp" #include "cppa/guard_expr.hpp"
#include "cppa/util/call.hpp" #include "cppa/util/call.hpp"
...@@ -56,7 +56,7 @@ struct collected_args_tuple { ...@@ -56,7 +56,7 @@ struct collected_args_tuple {
typename util::tl_map< typename util::tl_map<
ProjectionFuns, ProjectionFuns,
util::map_to_result_type, util::map_to_result_type,
util::rm_option util::rm_optional
>::type, >::type,
typename util::tl_map< typename util::tl_map<
util::type_list<Ts...>, util::type_list<Ts...>,
...@@ -142,7 +142,7 @@ class projection { ...@@ -142,7 +142,7 @@ class projection {
} }
template<class Storage> template<class Storage>
static inline bool store(Storage& storage, option<Storage>&& value) { static inline bool store(Storage& storage, optional<Storage>&& value) {
if (value) { if (value) {
storage = std::move(*value); storage = std::move(*value);
return true; return true;
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include <type_traits> #include <type_traits>
#include "cppa/get.hpp" #include "cppa/get.hpp"
#include "cppa/option.hpp" #include "cppa/optional.hpp"
#include "cppa/util/wrapped.hpp" #include "cppa/util/wrapped.hpp"
#include "cppa/util/type_list.hpp" #include "cppa/util/type_list.hpp"
......
...@@ -56,7 +56,7 @@ struct tuple_cast_impl { ...@@ -56,7 +56,7 @@ struct tuple_cast_impl {
static_cast<size_t>( static_cast<size_t>(
util::tl_find<util::type_list<T...>, anything>::value); util::tl_find<util::type_list<T...>, anything>::value);
typedef util::limited_vector<size_t, size> mapping_vector; typedef util::limited_vector<size_t, size> mapping_vector;
static inline option<Result> safe(any_tuple& tup) { static inline optional<Result> safe(any_tuple& tup) {
mapping_vector mv; mapping_vector mv;
if (matches<T...>(tup, mv)) return {Result::from(std::move(tup.vals()), if (matches<T...>(tup, mv)) return {Result::from(std::move(tup.vals()),
mv)}; mv)};
...@@ -66,7 +66,7 @@ struct tuple_cast_impl { ...@@ -66,7 +66,7 @@ struct tuple_cast_impl {
template<class Result, typename... T> template<class Result, typename... T>
struct tuple_cast_impl<wildcard_position::nil, Result, T...> { struct tuple_cast_impl<wildcard_position::nil, Result, T...> {
static inline option<Result> safe(any_tuple& tup) { static inline optional<Result> safe(any_tuple& tup) {
if (matches<T...>(tup)) return {Result::from(std::move(tup.vals()))}; if (matches<T...>(tup)) return {Result::from(std::move(tup.vals()))};
return {}; return {};
} }
...@@ -79,7 +79,7 @@ struct tuple_cast_impl<wildcard_position::trailing, Result, T...> ...@@ -79,7 +79,7 @@ struct tuple_cast_impl<wildcard_position::trailing, Result, T...>
template<class Result, typename... T> template<class Result, typename... T>
struct tuple_cast_impl<wildcard_position::leading, Result, T...> { struct tuple_cast_impl<wildcard_position::leading, Result, T...> {
static inline option<Result> safe(any_tuple& tup) { static inline optional<Result> safe(any_tuple& tup) {
size_t o = tup.size() - (sizeof...(T) - 1); size_t o = tup.size() - (sizeof...(T) - 1);
if (matches<T...>(tup)) return {Result::offset_subtuple(tup.vals(), o)}; if (matches<T...>(tup)) return {Result::offset_subtuple(tup.vals(), o)};
return {}; return {};
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#include <type_traits> #include <type_traits>
#include "cppa/config.hpp" #include "cppa/config.hpp"
#include "cppa/option.hpp" #include "cppa/optional.hpp"
#include "cppa/util/call.hpp" #include "cppa/util/call.hpp"
#include "cppa/util/void_type.hpp" #include "cppa/util/void_type.hpp"
...@@ -212,7 +212,7 @@ struct ge_get_front { ...@@ -212,7 +212,7 @@ struct ge_get_front {
decltype(what.front()) decltype(what.front())
>::value >::value
>::type* = 0) const >::type* = 0) const
-> option< -> optional<
std::reference_wrapper< std::reference_wrapper<
const typename util::rm_const_and_ref<decltype(what.front())>::type> > { const typename util::rm_const_and_ref<decltype(what.front())>::type> > {
if (what.empty() == false) return {what.front()}; if (what.empty() == false) return {what.front()};
...@@ -225,7 +225,7 @@ struct ge_get_front { ...@@ -225,7 +225,7 @@ struct ge_get_front {
decltype(what.front()) decltype(what.front())
>::value == false >::value == false
>::type* = 0) const >::type* = 0) const
-> option<decltype(what.front())> { -> optional<decltype(what.front())> {
if (what.empty() == false) return {what.front()}; if (what.empty() == false) return {what.front()};
return {}; return {};
} }
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <memory> #include <memory>
#include "cppa/config.hpp" #include "cppa/config.hpp"
#include "cppa/option.hpp" #include "cppa/optional.hpp"
#include "cppa/io/input_stream.hpp" #include "cppa/io/input_stream.hpp"
#include "cppa/io/output_stream.hpp" #include "cppa/io/output_stream.hpp"
...@@ -71,7 +71,7 @@ class acceptor { ...@@ -71,7 +71,7 @@ class acceptor {
* @brief Tries to accept a new connection but immediately returns if * @brief Tries to accept a new connection but immediately returns if
* there is no pending connection. * there is no pending connection.
*/ */
virtual option<stream_ptr_pair> try_accept_connection() = 0; virtual optional<stream_ptr_pair> try_accept_connection() = 0;
}; };
......
...@@ -52,7 +52,7 @@ class ipv4_acceptor : public acceptor { ...@@ -52,7 +52,7 @@ class ipv4_acceptor : public acceptor {
stream_ptr_pair accept_connection(); stream_ptr_pair accept_connection();
option<stream_ptr_pair> try_accept_connection(); optional<stream_ptr_pair> try_accept_connection();
private: private:
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#ifndef CPPA_MATCH_EXPR_HPP #ifndef CPPA_MATCH_EXPR_HPP
#define CPPA_MATCH_EXPR_HPP #define CPPA_MATCH_EXPR_HPP
#include "cppa/option.hpp" #include "cppa/optional.hpp"
#include "cppa/guard_expr.hpp" #include "cppa/guard_expr.hpp"
#include "cppa/tpartial_function.hpp" #include "cppa/tpartial_function.hpp"
...@@ -402,7 +402,7 @@ struct get_case_ { ...@@ -402,7 +402,7 @@ struct get_case_ {
typename util::tl_map< typename util::tl_map<
padded_transformers, padded_transformers,
util::map_to_result_type, util::map_to_result_type,
util::rm_option, util::rm_optional,
std::add_lvalue_reference std::add_lvalue_reference
>::type, >::type,
typename util::tl_zip< typename util::tl_zip<
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <algorithm> #include <algorithm>
#include <functional> #include <functional>
#include "cppa/option.hpp" #include "cppa/optional.hpp"
#include "cppa/cow_tuple.hpp" #include "cppa/cow_tuple.hpp"
#include "cppa/util/call.hpp" #include "cppa/util/call.hpp"
...@@ -104,7 +104,7 @@ struct cl_spawn_helper<R (Ts...), void> { ...@@ -104,7 +104,7 @@ struct cl_spawn_helper<R (Ts...), void> {
}; };
template<typename R, typename... Ts> template<typename R, typename... Ts>
struct cl_spawn_helper<std::function<option<cow_tuple<Ts...>> (any_tuple)>, struct cl_spawn_helper<std::function<optional<cow_tuple<Ts...>> (any_tuple)>,
std::function<any_tuple (R&)>> std::function<any_tuple (R&)>>
: cl_spawn_helper<R (Ts...)> { }; : cl_spawn_helper<R (Ts...)> { };
......
...@@ -70,7 +70,7 @@ class actor_facade<Ret(Args...)> : public actor { ...@@ -70,7 +70,7 @@ class actor_facade<Ret(Args...)> : public actor {
public: public:
typedef cow_tuple<typename util::rm_const_and_ref<Args>::type...> args_tuple; typedef cow_tuple<typename util::rm_const_and_ref<Args>::type...> args_tuple;
typedef std::function<option<args_tuple>(any_tuple)> arg_mapping; typedef std::function<optional<args_tuple>(any_tuple)> arg_mapping;
typedef std::function<any_tuple(Ret&)> result_mapping; typedef std::function<any_tuple(Ret&)> result_mapping;
static intrusive_ptr<actor_facade> create(const program& prog, static intrusive_ptr<actor_facade> create(const program& prog,
......
...@@ -38,14 +38,14 @@ ...@@ -38,14 +38,14 @@
#include <functional> #include <functional>
#include "cppa/on.hpp" #include "cppa/on.hpp"
#include "cppa/option.hpp" #include "cppa/optional.hpp"
#include "cppa/detail/demangle.hpp" #include "cppa/detail/demangle.hpp"
#include "cppa/detail/opt_impls.hpp" #include "cppa/detail/opt_impls.hpp"
namespace cppa { namespace cppa {
//template<typename T> //template<typename T>
//option<T> conv_arg(const std::string& arg) { //optional<T> conv_arg(const std::string& arg) {
// return detail::conv_arg_impl<T>::_(arg); // return detail::conv_arg_impl<T>::_(arg);
//} //}
......
...@@ -41,7 +41,7 @@ namespace cppa { ...@@ -41,7 +41,7 @@ namespace cppa {
* @brief Represents an optional value of @p T. * @brief Represents an optional value of @p T.
*/ */
template<typename T> template<typename T>
class option { class optional {
public: public:
...@@ -54,32 +54,32 @@ class option { ...@@ -54,32 +54,32 @@ class option {
* @brief Default constructor. * @brief Default constructor.
* @post <tt>valid() == false</tt> * @post <tt>valid() == false</tt>
*/ */
option() : m_valid(false) { } optional() : m_valid(false) { }
/** /**
* @brief Creates an @p option from @p value. * @brief Creates an @p option from @p value.
* @post <tt>valid() == true</tt> * @post <tt>valid() == true</tt>
*/ */
option(T value) : m_valid(false) { cr(std::move(value)); } optional(T value) : m_valid(false) { cr(std::move(value)); }
template<typename T0, typename T1, typename... Ts> template<typename T0, typename T1, typename... Ts>
option(T0&& arg0, T1&& arg1, Ts&&... args) : m_valid(false) { optional(T0&& arg0, T1&& arg1, Ts&&... args) : m_valid(false) {
cr(T(std::forward<T0>(arg0), cr(T(std::forward<T0>(arg0),
std::forward<T1>(arg1), std::forward<T1>(arg1),
std::forward<Ts>(args)...)); std::forward<Ts>(args)...));
} }
option(const option& other) : m_valid(false) { optional(const optional& other) : m_valid(false) {
if (other.m_valid) cr(other.m_value); if (other.m_valid) cr(other.m_value);
} }
option(option&& other) : m_valid(false) { optional(optional&& other) : m_valid(false) {
if (other.m_valid) cr(std::move(other.m_value)); if (other.m_valid) cr(std::move(other.m_value));
} }
~option() { destroy(); } ~optional() { destroy(); }
option& operator=(const option& other) { optional& operator=(const optional& other) {
if (m_valid) { if (m_valid) {
if (other.m_valid) m_value = other.m_value; if (other.m_valid) m_value = other.m_value;
else destroy(); else destroy();
...@@ -90,7 +90,7 @@ class option { ...@@ -90,7 +90,7 @@ class option {
return *this; return *this;
} }
option& operator=(option&& other) { optional& operator=(optional&& other) {
if (m_valid) { if (m_valid) {
if (other.m_valid) m_value = std::move(other.m_value); if (other.m_valid) m_value = std::move(other.m_value);
else destroy(); else destroy();
...@@ -186,19 +186,19 @@ class option { ...@@ -186,19 +186,19 @@ class option {
}; };
template<typename T> template<typename T>
class option<T&> { class optional<T&> {
public: public:
typedef T type; typedef T type;
option() : m_value(nullptr) { } optional() : m_value(nullptr) { }
option(T& value) : m_value(&value) { } optional(T& value) : m_value(&value) { }
option(const option& other) = default; optional(const optional& other) = default;
option& operator=(const option& other) = default; optional& operator=(const optional& other) = default;
inline bool valid() const { return m_value != nullptr; } inline bool valid() const { return m_value != nullptr; }
...@@ -241,46 +241,46 @@ class option<T&> { ...@@ -241,46 +241,46 @@ class option<T&> {
/** @relates option */ /** @relates option */
template<typename T> template<typename T>
struct is_option { static constexpr bool value = false; }; struct is_optional { static constexpr bool value = false; };
template<typename T> template<typename T>
struct is_option<option<T>> { static constexpr bool value = true; }; struct is_optional<optional<T>> { static constexpr bool value = true; };
/** @relates option */ /** @relates option */
template<typename T, typename U> template<typename T, typename U>
bool operator==(const option<T>& lhs, const option<U>& rhs) { bool operator==(const optional<T>& lhs, const optional<U>& rhs) {
if ((lhs) && (rhs)) return *lhs == *rhs; if ((lhs) && (rhs)) return *lhs == *rhs;
return false; return false;
} }
/** @relates option */ /** @relates option */
template<typename T, typename U> template<typename T, typename U>
bool operator==(const option<T>& lhs, const U& rhs) { bool operator==(const optional<T>& lhs, const U& rhs) {
if (lhs) return *lhs == rhs; if (lhs) return *lhs == rhs;
return false; return false;
} }
/** @relates option */ /** @relates option */
template<typename T, typename U> template<typename T, typename U>
bool operator==(const T& lhs, const option<U>& rhs) { bool operator==(const T& lhs, const optional<U>& rhs) {
return rhs == lhs; return rhs == lhs;
} }
/** @relates option */ /** @relates option */
template<typename T, typename U> template<typename T, typename U>
bool operator!=(const option<T>& lhs, const option<U>& rhs) { bool operator!=(const optional<T>& lhs, const optional<U>& rhs) {
return !(lhs == rhs); return !(lhs == rhs);
} }
/** @relates option */ /** @relates option */
template<typename T, typename U> template<typename T, typename U>
bool operator!=(const option<T>& lhs, const U& rhs) { bool operator!=(const optional<T>& lhs, const U& rhs) {
return !(lhs == rhs); return !(lhs == rhs);
} }
/** @relates option */ /** @relates option */
template<typename T, typename U> template<typename T, typename U>
bool operator!=(const T& lhs, const option<U>& rhs) { bool operator!=(const T& lhs, const optional<U>& rhs) {
return !(lhs == rhs); return !(lhs == rhs);
} }
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include <type_traits> #include <type_traits>
#include "cppa/option.hpp" #include "cppa/optional.hpp"
#include "cppa/util/type_list.hpp" #include "cppa/util/type_list.hpp"
...@@ -90,7 +90,7 @@ auto tuple_cast(any_tuple tup, const util::type_list<T...>&); ...@@ -90,7 +90,7 @@ auto tuple_cast(any_tuple tup, const util::type_list<T...>&);
template<typename... T> template<typename... T>
auto moving_tuple_cast(any_tuple& tup) auto moving_tuple_cast(any_tuple& tup)
-> option< -> optional<
typename cow_tuple_from_type_list< typename cow_tuple_from_type_list<
typename util::tl_filter_not<util::type_list<T...>, typename util::tl_filter_not<util::type_list<T...>,
is_anything>::type is_anything>::type
...@@ -110,7 +110,7 @@ auto moving_tuple_cast(any_tuple& tup, const util::type_list<T...>&) ...@@ -110,7 +110,7 @@ auto moving_tuple_cast(any_tuple& tup, const util::type_list<T...>&)
template<typename... T> template<typename... T>
auto tuple_cast(any_tuple tup) auto tuple_cast(any_tuple tup)
-> option< -> optional<
typename cow_tuple_from_type_list< typename cow_tuple_from_type_list<
typename util::tl_filter_not<util::type_list<T...>, typename util::tl_filter_not<util::type_list<T...>,
is_anything>::type is_anything>::type
......
...@@ -302,12 +302,12 @@ struct is_mutable_ref { ...@@ -302,12 +302,12 @@ struct is_mutable_ref {
* @brief Returns either @p T or @p T::type if @p T is an option. * @brief Returns either @p T or @p T::type if @p T is an option.
*/ */
template<typename T> template<typename T>
struct rm_option { struct rm_optional {
typedef T type; typedef T type;
}; };
template<typename T> template<typename T>
struct rm_option<option<T> > { struct rm_optional<optional<T> > {
typedef T type; typedef T type;
}; };
......
...@@ -162,7 +162,7 @@ void multiplier() { ...@@ -162,7 +162,7 @@ void multiplier() {
// to a tuple of vectors; note that this function returns // to a tuple of vectors; note that this function returns
// an option (an empty results causes the actor to ignore // an option (an empty results causes the actor to ignore
// the message) // the message)
[] (any_tuple msg) -> option<cow_tuple<fvec, fvec>> { [] (any_tuple msg) -> optional<cow_tuple<fvec, fvec>> {
auto opt = tuple_cast<matrix_type, matrix_type>(msg); auto opt = tuple_cast<matrix_type, matrix_type>(msg);
if (opt) { if (opt) {
return {move(get_ref<0>(*opt).data()), return {move(get_ref<0>(*opt).data()),
......
...@@ -140,7 +140,7 @@ void client_repl(const string& host, uint16_t port) { ...@@ -140,7 +140,7 @@ void client_repl(const string& host, uint16_t port) {
); );
} }
else { else {
auto toint = [](const string& str) -> option<int> { auto toint = [](const string& str) -> optional<int> {
try { return {std::stoi(str)}; } try { return {std::stoi(str)}; }
catch (std::exception&) { catch (std::exception&) {
aout << "\"" << str << "\" is not an integer" << endl; aout << "\"" << str << "\" is not an integer" << endl;
......
...@@ -62,7 +62,7 @@ struct behavior_stack_mover : iterator<output_iterator_tag, void, void, void, vo ...@@ -62,7 +62,7 @@ struct behavior_stack_mover : iterator<output_iterator_tag, void, void, void, vo
inline behavior_stack_mover move_iter(behavior_stack* bs) { return {bs}; } inline behavior_stack_mover move_iter(behavior_stack* bs) { return {bs}; }
option<behavior&> behavior_stack::sync_handler(message_id expected_response) { optional<behavior&> behavior_stack::sync_handler(message_id expected_response) {
if (expected_response.valid()) { if (expected_response.valid()) {
auto e = m_elements.rend(); auto e = m_elements.rend();
auto i = find_if(m_elements.rbegin(), e, [=](element_type& val) { auto i = find_if(m_elements.rbegin(), e, [=](element_type& val) {
......
...@@ -258,7 +258,7 @@ class broker::doorman : public broker::servant { ...@@ -258,7 +258,7 @@ class broker::doorman : public broker::servant {
continue_reading_result continue_reading() override { continue_reading_result continue_reading() override {
CPPA_LOG_TRACE(""); CPPA_LOG_TRACE("");
for (;;) { for (;;) {
option<stream_ptr_pair> opt; optional<stream_ptr_pair> opt;
try { opt = m_ptr->try_accept_connection(); } try { opt = m_ptr->try_accept_connection(); }
catch (std::exception& e) { catch (std::exception& e) {
CPPA_LOG_ERROR(to_verbose_string(e)); CPPA_LOG_ERROR(to_verbose_string(e));
......
...@@ -53,7 +53,7 @@ default_peer_acceptor::default_peer_acceptor(default_protocol* parent, ...@@ -53,7 +53,7 @@ default_peer_acceptor::default_peer_acceptor(default_protocol* parent,
continue_reading_result default_peer_acceptor::continue_reading() { continue_reading_result default_peer_acceptor::continue_reading() {
CPPA_LOG_TRACE(""); CPPA_LOG_TRACE("");
for (;;) { for (;;) {
option<stream_ptr_pair> opt; optional<stream_ptr_pair> opt;
try { opt = m_ptr->try_accept_connection(); } try { opt = m_ptr->try_accept_connection(); }
catch (exception& e) { catch (exception& e) {
CPPA_LOG_ERROR(to_verbose_string(e)); CPPA_LOG_ERROR(to_verbose_string(e));
......
...@@ -162,7 +162,7 @@ stream_ptr_pair ipv4_acceptor::accept_connection() { ...@@ -162,7 +162,7 @@ stream_ptr_pair ipv4_acceptor::accept_connection() {
return result; return result;
} }
option<stream_ptr_pair> ipv4_acceptor::try_accept_connection() { optional<stream_ptr_pair> ipv4_acceptor::try_accept_connection() {
if (!m_is_nonblocking) { if (!m_is_nonblocking) {
nonblocking(m_fd, true); nonblocking(m_fd, true);
m_is_nonblocking = true; m_is_nonblocking = true;
......
...@@ -51,7 +51,7 @@ detail::opt1_rvalue_builder<true> on_opt1(char short_opt, ...@@ -51,7 +51,7 @@ detail::opt1_rvalue_builder<true> on_opt1(char short_opt,
string prefix = "--"; string prefix = "--";
prefix += long_opt; prefix += long_opt;
prefix += "="; prefix += "=";
function<option<string> (const string&)> kvp = [prefix](const string& input) -> option<string> { function<optional<string> (const string&)> kvp = [prefix](const string& input) -> optional<string> {
if (equal(begin(prefix), end(prefix), begin(input))) { if (equal(begin(prefix), end(prefix), begin(input))) {
return input.substr(prefix.size()); return input.substr(prefix.size());
} }
......
...@@ -284,7 +284,7 @@ int main() { ...@@ -284,7 +284,7 @@ int main() {
CPPA_CHECK(invoked); CPPA_CHECK(invoked);
invoked = false; invoked = false;
auto toint = [](const string& str) -> option<int> { auto toint = [](const string& str) -> optional<int> {
char* endptr = nullptr; char* endptr = nullptr;
int result = static_cast<int>(strtol(str.c_str(), &endptr, 10)); int result = static_cast<int>(strtol(str.c_str(), &endptr, 10));
if (endptr != nullptr && *endptr == '\0') { if (endptr != nullptr && *endptr == '\0') {
...@@ -425,7 +425,7 @@ int main() { ...@@ -425,7 +425,7 @@ int main() {
); );
CPPA_CHECK_EQUAL(success, true); CPPA_CHECK_EQUAL(success, true);
auto extract_name = [](const string& kvp) -> option<string> { auto extract_name = [](const string& kvp) -> optional<string> {
auto vec = split(kvp, '='); auto vec = split(kvp, '=');
if (vec.size() == 2) { if (vec.size() == 2) {
if (vec.front() == "--name") { if (vec.front() == "--name") {
......
...@@ -140,7 +140,7 @@ int main() { ...@@ -140,7 +140,7 @@ int main() {
const matrix_type expected2(move(expected1)); const matrix_type expected2(move(expected1));
auto map_args = [] (any_tuple msg) -> option<cow_tuple<ivec>> { auto map_args = [] (any_tuple msg) -> optional<cow_tuple<ivec>> {
auto opt = tuple_cast<matrix_type>(msg); auto opt = tuple_cast<matrix_type>(msg);
if (opt) { if (opt) {
return {make_cow_tuple(move(get_ref<0>(*opt).data()))}; return {make_cow_tuple(move(get_ref<0>(*opt).data()))};
......
...@@ -66,7 +66,7 @@ std::string int2str(int i) { ...@@ -66,7 +66,7 @@ std::string int2str(int i) {
return std::to_string(i); return std::to_string(i);
} }
option<int> str2int(const std::string& str) { optional<int> str2int(const std::string& str) {
char* endptr = nullptr; char* endptr = nullptr;
int result = static_cast<int>(strtol(str.c_str(), &endptr, 10)); int result = static_cast<int>(strtol(str.c_str(), &endptr, 10));
if (endptr != nullptr && *endptr == '\0') { if (endptr != nullptr && *endptr == '\0') {
...@@ -336,7 +336,7 @@ void check_wildcards() { ...@@ -336,7 +336,7 @@ void check_wildcards() {
// use tuple cast to get a subtuple // use tuple cast to get a subtuple
any_tuple at0(t0); any_tuple at0(t0);
auto v0opt = tuple_cast<std::string, anything>(at0); auto v0opt = tuple_cast<std::string, anything>(at0);
CPPA_CHECK((std::is_same<decltype(v0opt), option<cow_tuple<std::string>>>::value)); CPPA_CHECK((std::is_same<decltype(v0opt), optional<cow_tuple<std::string>>>::value));
CPPA_CHECK((v0opt)); CPPA_CHECK((v0opt));
CPPA_CHECK( at0.size() == 2 CPPA_CHECK( at0.size() == 2
&& at0.at(0) == &get<0>(t0) && at0.at(0) == &get<0>(t0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment