-CXXFLAGS ?= -g -MMD -Werror -I. -std=c++11
+CXXFLAGS ?= -g -MMD -Werror -I. -std=c++1y
LDFLAGS ?=
CXX ?= g++
CC ?= g++
PEDANTRY =
STDLIB =
OPTFLAGS = -O3 #-fno-omit-frame-pointer -fsanitize=address ,thread,undefined -fsanitize-memory-track-origins
-CXXFLAGS = -std=c++11 -ggdb3 -MMD -I. $(STDLIB) $(PEDANTRY) $(OPTFLAGS)
-LDFLAGS = -std=c++11 $(STDLIB) $(OPTFLAGS)
+CXXFLAGS = -std=c++1y -ggdb3 -MMD -I. $(STDLIB) $(PEDANTRY) $(OPTFLAGS)
+LDFLAGS = -std=c++1y $(STDLIB) $(OPTFLAGS)
ifeq "$(USE_CLANG)" "1"
template <class... Args, size_t... Indices>
inline tuple<typename std::remove_reference<Args>::type...>
-tuple_hton_imp(tuple<Args...> && t, tuple_indices<Indices...>) {
+tuple_hton_imp(tuple<Args...> && t, std::index_sequence<Indices...>) {
return tuple<
typename std::remove_reference<Args>::type...
>(hton(std::get<Indices>(t))...);
template <class... Args>
inline tuple<typename std::remove_reference<Args>::type...>
hton(tuple<Args...> && t) {
- return tuple_hton_imp(std::forward<tuple<Args...>>(t), TUPLE_INDICES(Args));
+ return tuple_hton_imp(std::forward<tuple<Args...>>(t), std::index_sequence_for<Args...>{});
}
template <class T> inline typename
lock_client::lock_client(string xdst, lock_release_user *_lu) : lu(_lu), next_xid(0) {
rlock_port = std::uniform_int_distribution<in_port_t>(1024,32000+1024)(global->random_generator);
id = "127.0.0.1:" + std::to_string(rlock_port);
- rlsrpc = unique_ptr<rpcs>(new rpcs(rlock_port));
+ rlsrpc = std::make_unique<rpcs>(rlock_port);
rlsrpc->reg(rlock_protocol::revoke, &lock_client::revoke_handler, this);
rlsrpc->reg(rlock_protocol::retry, &lock_client::retry_handler, this);
- rsmc = unique_ptr<rsm_client>(new rsm_client(xdst));
+ rsmc = std::make_unique<rsm_client>(xdst);
releaser_thread = thread(&lock_client::releaser, this);
rlsrpc->start();
}
// the appropriate tag struct to make this possible.
template <class... Args, size_t... Indices> inline marshall &
-tuple_marshall_imp(marshall & m, tuple<Args...> & t, tuple_indices<Indices...>) {
+tuple_marshall_imp(marshall & m, tuple<Args...> & t, std::index_sequence<Indices...>) {
// Note that brace initialization is used for the empty structure "pack",
// forcing the comma-separated expressions expanded from the parameter pack
// to be evaluated in order. Order matters because the elements must be
template <class... Args> inline marshall &
operator<<(marshall & m, tuple<Args...> && t) {
- return tuple_marshall_imp(m, t, TUPLE_INDICES(Args));
+ return tuple_marshall_imp(m, t, std::index_sequence_for<Args...>{});
}
template <class... Args, size_t... Indices> inline unmarshall &
-tuple_unmarshall_imp(unmarshall & u, tuple<Args & ...> t, tuple_indices<Indices...>) {
+tuple_unmarshall_imp(unmarshall & u, tuple<Args & ...> t, std::index_sequence<Indices...>) {
(void)pass{(u >> std::get<Indices>(t))...};
return u;
}
template <class... Args> inline unmarshall &
operator>>(unmarshall & u, tuple<Args & ...> && t) {
- return tuple_unmarshall_imp(u, t, TUPLE_INDICES(Args));
+ return tuple_unmarshall_imp(u, t, std::index_sequence_for<Args...>{});
}
//
//
// We implement an 'invoke' function for functions of the RPC handler
// signature, i.e. int(R & r, const Args...)
-//
-// One thing we need in order to accomplish this is a way to cause the compiler
-// to specialize 'invoke' with a parameter pack containing a list of indices
-// for the elements of the tuple. This will allow us to call the underlying
-// function with the exploded contents of the tuple. The empty type
-// tuple_indices<size_t...> accomplishes this. It will be passed in to
-// 'invoke' as a parameter which will be ignored, but its type will force the
-// compiler to specialize 'invoke' appropriately.
// This class encapsulates the default response to runtime unmarshalling
// failures. The templated wrappers below may optionally use a different
template <class F, class R, class RV, class args_type, size_t... Indices>
typename enable_if<!std::is_member_function_pointer<F>::value, RV>::type inline
-invoke(RV, F f, void *, R & r, args_type & t, tuple_indices<Indices...>) {
+invoke(RV, F f, void *, R & r, args_type & t, std::index_sequence<Indices...>) {
return f(r, std::get<Indices>(t)...);
}
template <class F, class C, class RV, class R, class args_type, size_t... Indices>
typename enable_if<std::is_member_function_pointer<F>::value, RV>::type inline
-invoke(RV, F f, C *c, R & r, args_type & t, tuple_indices<Indices...>) {
+invoke(RV, F f, C *c, R & r, args_type & t, std::index_sequence<Indices...>) {
return (c->*f)(r, std::get<Indices>(t)...);
}
// Allocate space for the RPC response -- will be passed into the
// function as an lvalue reference.
R r;
- // Perform the invocation. Note that TUPLE_INDICES calls the
- // default constructor of an empty struct with template parameters
- // running from 0 up to (# args) - 1.
- RV b = invoke(RV(), f, c, r, t, TUPLE_INDICES(Args));
+ // Perform the invocation.
+ RV b = invoke(RV(), f, c, r, t, std::index_sequence_for<Args...>{});
// Marshall the response.
m << r;
// Make like a tree.
rsm::rsm(const string & _first, const string & _me) : primary(_first)
{
- cfg = unique_ptr<config>(new config(_first, _me, this));
+ cfg = std::make_unique<config>(_first, _me, this);
if (_first == _me) {
// Commit the first view here. We can not have acceptor::acceptor
// };
#define MEMBERS(...) \
-inline auto _tuple_() -> decltype(std::tie(__VA_ARGS__)) { return std::tie(__VA_ARGS__); } \
-inline auto _tuple_() const -> decltype(std::tie(__VA_ARGS__)) { return std::tie(__VA_ARGS__); }
+inline auto _tuple_() { return std::tie(__VA_ARGS__); } \
+inline auto _tuple_() const { return std::tie(__VA_ARGS__); }
// struct ordering and comparison operations; requires the use of MEMBERS.
// usage:
LEXICOGRAPHIC_OPERATOR(_c_, >) LEXICOGRAPHIC_OPERATOR(_c_, >=) \
LEXICOGRAPHIC_OPERATOR(_c_, ==) LEXICOGRAPHIC_OPERATOR(_c_, !=)
-// Tuple indexing in variadic templates.
-// This implementation of tuple_indices is redistributed under the MIT
-// License as an insubstantial portion of the LLVM compiler infrastructure.
-
-template <size_t...> struct tuple_indices {};
-template <size_t S, class IntTuple, size_t E> struct make_indices_imp;
-template <size_t S, size_t... Indices, size_t E> struct make_indices_imp<S, tuple_indices<Indices...>, E> {
- typedef typename make_indices_imp<S+1, tuple_indices<Indices..., S>, E>::type type;
-};
-template <size_t E, size_t... Indices> struct make_indices_imp<E, tuple_indices<Indices...>, E> {
- typedef tuple_indices<Indices...> type;
-};
-template <size_t E, size_t S=0> struct make_tuple_indices {
- typedef typename make_indices_imp<S, tuple_indices<>, E>::type type;
-};
-
-#define TUPLE_INDICES(_ArgPack_) typename make_tuple_indices<sizeof...(_ArgPack_)>::type()
-
// Template parameter pack expansion is not allowed in certain contexts, but
// brace initializers (for instance, calls to constructors of empty structs)
// are fair game.