Update clang-format to 13.0.1.
This commit is contained in:
parent
5a76413990
commit
1bb9b7dfa9
@ -45,9 +45,9 @@ extern void *__libc_stack_end;
|
||||
static void *get_bp() {
|
||||
void *bp;
|
||||
#if defined(__i386__)
|
||||
__asm__ volatile("movl %%ebp, %[r]" : [ r ] "=r"(bp));
|
||||
__asm__ volatile("movl %%ebp, %[r]" : [r] "=r"(bp));
|
||||
#elif defined(__x86_64__)
|
||||
__asm__ volatile("movq %%rbp, %[r]" : [ r ] "=r"(bp));
|
||||
__asm__ volatile("movq %%rbp, %[r]" : [r] "=r"(bp));
|
||||
#endif
|
||||
return bp;
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ class Td final : public Actor {
|
||||
void set_is_bot_online(bool is_bot_online);
|
||||
|
||||
template <class ActorT, class... ArgsT>
|
||||
ActorId<ActorT> create_net_actor(ArgsT &&... args) {
|
||||
ActorId<ActorT> create_net_actor(ArgsT &&...args) {
|
||||
LOG_CHECK(close_flag_ < 1) << close_flag_
|
||||
#if TD_CLANG || TD_GCC
|
||||
<< ' ' << __PRETTY_FUNCTION__
|
||||
@ -234,7 +234,7 @@ class Td final : public Actor {
|
||||
};
|
||||
|
||||
template <class HandlerT, class... Args>
|
||||
std::shared_ptr<HandlerT> create_handler(Args &&... args) {
|
||||
std::shared_ptr<HandlerT> create_handler(Args &&...args) {
|
||||
LOG_CHECK(close_flag_ < 2) << close_flag_
|
||||
#if TD_CLANG || TD_GCC
|
||||
<< ' ' << __PRETTY_FUNCTION__
|
||||
|
@ -711,7 +711,7 @@ class CliClient final : public Actor {
|
||||
}
|
||||
|
||||
template <class FirstType, class SecondType, class... Types>
|
||||
static void get_args(string &args, FirstType &first_arg, SecondType &second_arg, Types &... other_args) {
|
||||
static void get_args(string &args, FirstType &first_arg, SecondType &second_arg, Types &...other_args) {
|
||||
string arg;
|
||||
std::tie(arg, args) = split(args);
|
||||
get_args(arg, first_arg);
|
||||
|
@ -199,7 +199,7 @@ using tl_object_ptr = tl::unique_ptr<Type>;
|
||||
* \return Wrapped pointer to the created TL-object.
|
||||
*/
|
||||
template <class Type, class... Args>
|
||||
tl_object_ptr<Type> make_tl_object(Args &&... args) {
|
||||
tl_object_ptr<Type> make_tl_object(Args &&...args) {
|
||||
return tl_object_ptr<Type>(new Type(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ class ConcurrentScheduler final : private Scheduler::Callback {
|
||||
void finish();
|
||||
|
||||
template <class ActorT, class... Args>
|
||||
ActorOwn<ActorT> create_actor_unsafe(int32 sched_id, Slice name, Args &&... args) {
|
||||
ActorOwn<ActorT> create_actor_unsafe(int32 sched_id, Slice name, Args &&...args) {
|
||||
#if TD_THREAD_UNSUPPORTED || TD_EVENTFD_UNSUPPORTED
|
||||
sched_id = 0;
|
||||
#endif
|
||||
|
@ -404,7 +404,7 @@ template <class PromiseT>
|
||||
class CancellablePromise final : public PromiseT {
|
||||
public:
|
||||
template <class... ArgsT>
|
||||
CancellablePromise(CancellationToken cancellation_token, ArgsT &&... args)
|
||||
CancellablePromise(CancellationToken cancellation_token, ArgsT &&...args)
|
||||
: PromiseT(std::forward<ArgsT>(args)...), cancellation_token_(std::move(cancellation_token)) {
|
||||
}
|
||||
bool is_cancellable() const final {
|
||||
@ -421,7 +421,7 @@ class CancellablePromise final : public PromiseT {
|
||||
template <class... ArgsT>
|
||||
class JoinPromise final : public PromiseInterface<Unit> {
|
||||
public:
|
||||
explicit JoinPromise(ArgsT &&... arg) : promises_(std::forward<ArgsT>(arg)...) {
|
||||
explicit JoinPromise(ArgsT &&...arg) : promises_(std::forward<ArgsT>(arg)...) {
|
||||
}
|
||||
void set_value(Unit &&) final {
|
||||
tuple_for_each(promises_, [](auto &promise) { promise.set_value(Unit()); });
|
||||
@ -438,7 +438,7 @@ class JoinPromise final : public PromiseInterface<Unit> {
|
||||
class SendClosure {
|
||||
public:
|
||||
template <class... ArgsT>
|
||||
void operator()(ArgsT &&... args) const {
|
||||
void operator()(ArgsT &&...args) const {
|
||||
send_closure(std::forward<ArgsT>(args)...);
|
||||
}
|
||||
};
|
||||
@ -453,7 +453,7 @@ class SendClosure {
|
||||
//}
|
||||
|
||||
template <class... ArgsT>
|
||||
auto promise_send_closure(ArgsT &&... args) {
|
||||
auto promise_send_closure(ArgsT &&...args) {
|
||||
return [t = std::make_tuple(std::forward<ArgsT>(args)...)](auto &&res) mutable {
|
||||
call_tuple(SendClosure(), std::tuple_cat(std::move(t), std::make_tuple(std::forward<decltype(res)>(res))));
|
||||
};
|
||||
@ -679,7 +679,7 @@ class PromiseFuture {
|
||||
template <ActorSendType send_type, class T, class ActorAT, class ActorBT, class ResultT, class... DestArgsT,
|
||||
class... ArgsT>
|
||||
FutureActor<T> send_promise(ActorId<ActorAT> actor_id, ResultT (ActorBT::*func)(PromiseActor<T> &&, DestArgsT...),
|
||||
ArgsT &&... args) {
|
||||
ArgsT &&...args) {
|
||||
PromiseFuture<T> pf;
|
||||
Scheduler::instance()->send_closure<send_type>(
|
||||
std::move(actor_id), create_immediate_closure(func, pf.move_promise(), std::forward<ArgsT>(args)...));
|
||||
@ -716,7 +716,7 @@ class PromiseCreator {
|
||||
}
|
||||
|
||||
template <class... ArgsT>
|
||||
static Promise<> join(ArgsT &&... args) {
|
||||
static Promise<> join(ArgsT &&...args) {
|
||||
return Promise<>(td::make_unique<detail::JoinPromise<ArgsT...>>(std::forward<ArgsT>(args)...));
|
||||
}
|
||||
|
||||
|
@ -90,10 +90,10 @@ class Actor : public ObserverBase {
|
||||
bool empty() const;
|
||||
|
||||
template <class FuncT, class... ArgsT>
|
||||
auto self_closure(FuncT &&func, ArgsT &&... args);
|
||||
auto self_closure(FuncT &&func, ArgsT &&...args);
|
||||
|
||||
template <class SelfT, class FuncT, class... ArgsT>
|
||||
auto self_closure(SelfT *self, FuncT &&func, ArgsT &&... args);
|
||||
auto self_closure(SelfT *self, FuncT &&func, ArgsT &&...args);
|
||||
|
||||
template <class LambdaT>
|
||||
auto self_lambda(LambdaT &&lambda);
|
||||
|
@ -146,12 +146,12 @@ ActorShared<SelfT> Actor::actor_shared(SelfT *self, uint64 id) {
|
||||
}
|
||||
|
||||
template <class FuncT, class... ArgsT>
|
||||
auto Actor::self_closure(FuncT &&func, ArgsT &&... args) {
|
||||
auto Actor::self_closure(FuncT &&func, ArgsT &&...args) {
|
||||
return self_closure(this, std::forward<FuncT>(func), std::forward<ArgsT>(args)...);
|
||||
}
|
||||
|
||||
template <class SelfT, class FuncT, class... ArgsT>
|
||||
auto Actor::self_closure(SelfT *self, FuncT &&func, ArgsT &&... args) {
|
||||
auto Actor::self_closure(SelfT *self, FuncT &&func, ArgsT &&...args) {
|
||||
return EventCreator::closure(actor_id(self), std::forward<FuncT>(func), std::forward<ArgsT>(args)...);
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ class ClosureEvent final : public CustomEvent {
|
||||
return new ClosureEvent<ClosureT>(closure_.clone());
|
||||
}
|
||||
template <class... ArgsT>
|
||||
explicit ClosureEvent(ArgsT &&... args) : closure_(std::forward<ArgsT>(args)...) {
|
||||
explicit ClosureEvent(ArgsT &&...args) : closure_(std::forward<ArgsT>(args)...) {
|
||||
}
|
||||
|
||||
void start_migrate(int32 sched_id) final {
|
||||
@ -152,7 +152,7 @@ class Event {
|
||||
new ClosureEvent<typename FromImmediateClosureT::Delayed>(std::forward<FromImmediateClosureT>(closure)));
|
||||
}
|
||||
template <class... ArgsT>
|
||||
static Event delayed_closure(ArgsT &&... args) {
|
||||
static Event delayed_closure(ArgsT &&...args) {
|
||||
using DelayedClosureT = decltype(create_delayed_closure(std::forward<ArgsT>(args)...));
|
||||
return custom(new ClosureEvent<DelayedClosureT>(std::forward<ArgsT>(args)...));
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class EventFull {
|
||||
class EventCreator {
|
||||
public:
|
||||
template <class ActorIdT, class FunctionT, class... ArgsT>
|
||||
static EventFull closure(ActorIdT &&actor_id, FunctionT function, ArgsT &&... args) {
|
||||
static EventFull closure(ActorIdT &&actor_id, FunctionT function, ArgsT &&...args) {
|
||||
using ActorT = typename std::decay_t<ActorIdT>::ActorT;
|
||||
using FunctionClassT = member_function_class_t<FunctionT>;
|
||||
static_assert(std::is_base_of<FunctionClassT, ActorT>::value, "unsafe send_closure");
|
||||
|
@ -84,9 +84,9 @@ class Scheduler {
|
||||
int32 sched_count() const;
|
||||
|
||||
template <class ActorT, class... Args>
|
||||
TD_WARN_UNUSED_RESULT ActorOwn<ActorT> create_actor(Slice name, Args &&... args);
|
||||
TD_WARN_UNUSED_RESULT ActorOwn<ActorT> create_actor(Slice name, Args &&...args);
|
||||
template <class ActorT, class... Args>
|
||||
TD_WARN_UNUSED_RESULT ActorOwn<ActorT> create_actor_on_scheduler(Slice name, int32 sched_id, Args &&... args);
|
||||
TD_WARN_UNUSED_RESULT ActorOwn<ActorT> create_actor_on_scheduler(Slice name, int32 sched_id, Args &&...args);
|
||||
template <class ActorT>
|
||||
TD_WARN_UNUSED_RESULT ActorOwn<ActorT> register_actor(Slice name, ActorT *actor_ptr, int32 sched_id = -1);
|
||||
template <class ActorT>
|
||||
@ -244,9 +244,9 @@ class Scheduler {
|
||||
|
||||
/*** Interface to current scheduler ***/
|
||||
template <class ActorT, class... Args>
|
||||
TD_WARN_UNUSED_RESULT ActorOwn<ActorT> create_actor(Slice name, Args &&... args);
|
||||
TD_WARN_UNUSED_RESULT ActorOwn<ActorT> create_actor(Slice name, Args &&...args);
|
||||
template <class ActorT, class... Args>
|
||||
TD_WARN_UNUSED_RESULT ActorOwn<ActorT> create_actor_on_scheduler(Slice name, int32 sched_id, Args &&... args);
|
||||
TD_WARN_UNUSED_RESULT ActorOwn<ActorT> create_actor_on_scheduler(Slice name, int32 sched_id, Args &&...args);
|
||||
template <class ActorT>
|
||||
TD_WARN_UNUSED_RESULT ActorOwn<ActorT> register_actor(Slice name, ActorT *actor_ptr, int32 sched_id = -1);
|
||||
template <class ActorT>
|
||||
@ -256,7 +256,7 @@ template <class ActorT>
|
||||
TD_WARN_UNUSED_RESULT ActorOwn<ActorT> register_existing_actor(unique_ptr<ActorT> actor_ptr);
|
||||
|
||||
template <class ActorIdT, class FunctionT, class... ArgsT>
|
||||
void send_closure(ActorIdT &&actor_id, FunctionT function, ArgsT &&... args) {
|
||||
void send_closure(ActorIdT &&actor_id, FunctionT function, ArgsT &&...args) {
|
||||
using ActorT = typename std::decay_t<ActorIdT>::ActorT;
|
||||
using FunctionClassT = member_function_class_t<FunctionT>;
|
||||
static_assert(std::is_base_of<FunctionClassT, ActorT>::value, "unsafe send_closure");
|
||||
@ -266,7 +266,7 @@ void send_closure(ActorIdT &&actor_id, FunctionT function, ArgsT &&... args) {
|
||||
}
|
||||
|
||||
template <class ActorIdT, class FunctionT, class... ArgsT>
|
||||
void send_closure_later(ActorIdT &&actor_id, FunctionT function, ArgsT &&... args) {
|
||||
void send_closure_later(ActorIdT &&actor_id, FunctionT function, ArgsT &&...args) {
|
||||
using ActorT = typename std::decay_t<ActorIdT>::ActorT;
|
||||
using FunctionClassT = member_function_class_t<FunctionT>;
|
||||
static_assert(std::is_base_of<FunctionClassT, ActorT>::value, "unsafe send_closure");
|
||||
@ -276,17 +276,17 @@ void send_closure_later(ActorIdT &&actor_id, FunctionT function, ArgsT &&... arg
|
||||
}
|
||||
|
||||
template <class... ArgsT>
|
||||
void send_lambda(ActorRef actor_ref, ArgsT &&... args) {
|
||||
void send_lambda(ActorRef actor_ref, ArgsT &&...args) {
|
||||
Scheduler::instance()->send_lambda<ActorSendType::Immediate>(actor_ref, std::forward<ArgsT>(args)...);
|
||||
}
|
||||
|
||||
template <class... ArgsT>
|
||||
void send_event(ActorRef actor_ref, ArgsT &&... args) {
|
||||
void send_event(ActorRef actor_ref, ArgsT &&...args) {
|
||||
Scheduler::instance()->send<ActorSendType::Immediate>(actor_ref, std::forward<ArgsT>(args)...);
|
||||
}
|
||||
|
||||
template <class... ArgsT>
|
||||
void send_event_later(ActorRef actor_ref, ArgsT &&... args) {
|
||||
void send_event_later(ActorRef actor_ref, ArgsT &&...args) {
|
||||
Scheduler::instance()->send<ActorSendType::Later>(actor_ref, std::forward<ArgsT>(args)...);
|
||||
}
|
||||
|
||||
|
@ -69,12 +69,12 @@ inline int32 Scheduler::sched_count() const {
|
||||
}
|
||||
|
||||
template <class ActorT, class... Args>
|
||||
ActorOwn<ActorT> Scheduler::create_actor(Slice name, Args &&... args) {
|
||||
ActorOwn<ActorT> Scheduler::create_actor(Slice name, Args &&...args) {
|
||||
return register_actor_impl(name, new ActorT(std::forward<Args>(args)...), Actor::Deleter::Destroy, sched_id_);
|
||||
}
|
||||
|
||||
template <class ActorT, class... Args>
|
||||
ActorOwn<ActorT> Scheduler::create_actor_on_scheduler(Slice name, int32 sched_id, Args &&... args) {
|
||||
ActorOwn<ActorT> Scheduler::create_actor_on_scheduler(Slice name, int32 sched_id, Args &&...args) {
|
||||
return register_actor_impl(name, new ActorT(std::forward<Args>(args)...), Actor::Deleter::Destroy, sched_id);
|
||||
}
|
||||
|
||||
@ -334,12 +334,12 @@ inline void Scheduler::run(Timestamp timeout) {
|
||||
|
||||
/*** Interface to current scheduler ***/
|
||||
template <class ActorT, class... Args>
|
||||
ActorOwn<ActorT> create_actor(Slice name, Args &&... args) {
|
||||
ActorOwn<ActorT> create_actor(Slice name, Args &&...args) {
|
||||
return Scheduler::instance()->create_actor<ActorT>(name, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <class ActorT, class... Args>
|
||||
ActorOwn<ActorT> create_actor_on_scheduler(Slice name, int32 sched_id, Args &&... args) {
|
||||
ActorOwn<ActorT> create_actor_on_scheduler(Slice name, int32 sched_id, Args &&...args) {
|
||||
return Scheduler::instance()->create_actor_on_scheduler<ActorT>(name, sched_id, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ class ImmediateClosure {
|
||||
|
||||
template <class ActorT, class ResultT, class... DestArgsT, class... SrcArgsT>
|
||||
ImmediateClosure<ActorT, ResultT (ActorT::*)(DestArgsT...), SrcArgsT &&...> create_immediate_closure(
|
||||
ResultT (ActorT::*func)(DestArgsT...), SrcArgsT &&... args) {
|
||||
ResultT (ActorT::*func)(DestArgsT...), SrcArgsT &&...args) {
|
||||
return ImmediateClosure<ActorT, ResultT (ActorT::*)(DestArgsT...), SrcArgsT &&...>(func,
|
||||
std::forward<SrcArgsT>(args)...);
|
||||
}
|
||||
@ -160,7 +160,7 @@ DelayedClosure<ArgsT...> to_delayed_closure(DelayedClosure<ArgsT...> &&other) {
|
||||
}
|
||||
|
||||
template <class ActorT, class ResultT, class... DestArgsT, class... SrcArgsT>
|
||||
auto create_delayed_closure(ResultT (ActorT::*func)(DestArgsT...), SrcArgsT &&... args) {
|
||||
auto create_delayed_closure(ResultT (ActorT::*func)(DestArgsT...), SrcArgsT &&...args) {
|
||||
return DelayedClosure<ActorT, ResultT (ActorT::*)(DestArgsT...), SrcArgsT &&...>(func,
|
||||
std::forward<SrcArgsT>(args)...);
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ class ObjectPool {
|
||||
};
|
||||
|
||||
template <class... ArgsT>
|
||||
OwnerPtr create(ArgsT &&... args) {
|
||||
OwnerPtr create(ArgsT &&...args) {
|
||||
Storage *storage = get_storage();
|
||||
storage->init_data(std::forward<ArgsT>(args)...);
|
||||
return OwnerPtr(storage, this);
|
||||
@ -201,7 +201,7 @@ class ObjectPool {
|
||||
std::atomic<int32> generation{1};
|
||||
|
||||
template <class... ArgsT>
|
||||
void init_data(ArgsT &&... args) {
|
||||
void init_data(ArgsT &&...args) {
|
||||
// new (&data) DataT(std::forward<ArgsT>(args)...);
|
||||
data = DataT(std::forward<ArgsT>(args)...);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ class SharedPtrRaw
|
||||
CHECK(option_magic_ == Magic);
|
||||
}
|
||||
template <class... ArgsT>
|
||||
void init_data(ArgsT &&... args) {
|
||||
void init_data(ArgsT &&...args) {
|
||||
new (&option_data_) DataT(std::forward<ArgsT>(args)...);
|
||||
}
|
||||
void destroy_data() {
|
||||
@ -158,13 +158,13 @@ class SharedPtr {
|
||||
}
|
||||
|
||||
template <class... ArgsT>
|
||||
static SharedPtr<T, DeleterT> create(ArgsT &&... args) {
|
||||
static SharedPtr<T, DeleterT> create(ArgsT &&...args) {
|
||||
auto raw = make_unique<Raw>(DeleterT());
|
||||
raw->init_data(std::forward<ArgsT>(args)...);
|
||||
return SharedPtr<T, DeleterT>(raw.release());
|
||||
}
|
||||
template <class D, class... ArgsT>
|
||||
static SharedPtr<T, DeleterT> create_with_deleter(D &&d, ArgsT &&... args) {
|
||||
static SharedPtr<T, DeleterT> create_with_deleter(D &&d, ArgsT &&...args) {
|
||||
auto raw = make_unique<Raw>(std::forward<D>(d));
|
||||
raw->init_data(std::forward<ArgsT>(args)...);
|
||||
return SharedPtr<T, DeleterT>(raw.release());
|
||||
@ -201,7 +201,7 @@ class SharedObjectPool {
|
||||
}
|
||||
|
||||
template <class... ArgsT>
|
||||
Ptr alloc(ArgsT &&... args) {
|
||||
Ptr alloc(ArgsT &&...args) {
|
||||
auto *raw = alloc_raw();
|
||||
raw->init_data(std::forward<ArgsT>(args)...);
|
||||
return Ptr(raw);
|
||||
|
@ -416,7 +416,7 @@ class Result {
|
||||
}
|
||||
struct emplace_t {};
|
||||
template <class... ArgsT>
|
||||
Result(emplace_t, ArgsT &&... args) : status_(), value_(std::forward<ArgsT>(args)...) {
|
||||
Result(emplace_t, ArgsT &&...args) : status_(), value_(std::forward<ArgsT>(args)...) {
|
||||
}
|
||||
Result(Status &&status) : status_(std::move(status)) {
|
||||
CHECK(status_.is_error());
|
||||
@ -451,7 +451,7 @@ class Result {
|
||||
return *this;
|
||||
}
|
||||
template <class... ArgsT>
|
||||
void emplace(ArgsT &&... args) {
|
||||
void emplace(ArgsT &&...args) {
|
||||
if (status_.is_ok()) {
|
||||
value_.~T();
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ class VectorQueue {
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
void emplace(Args &&... args) {
|
||||
void emplace(Args &&...args) {
|
||||
vector_.emplace_back(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
|
@ -301,7 +301,7 @@ StringBuilder &operator<<(StringBuilder &sb, const Concat<T> &concat) {
|
||||
}
|
||||
|
||||
template <class... ArgsT>
|
||||
auto concat(const ArgsT &... args) {
|
||||
auto concat(const ArgsT &...args) {
|
||||
return Concat<decltype(std::tie(args...))>{std::tie(args...)};
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ struct is_reference_wrapper<std::reference_wrapper<U>> : std::true_type {};
|
||||
|
||||
template <class Base, class T, class Derived, class... Args>
|
||||
auto invoke_impl(T Base::*pmf, Derived &&ref,
|
||||
Args &&... args) noexcept(noexcept((std::forward<Derived>(ref).*pmf)(std::forward<Args>(args)...)))
|
||||
Args &&...args) noexcept(noexcept((std::forward<Derived>(ref).*pmf)(std::forward<Args>(args)...)))
|
||||
-> std::enable_if_t<std::is_function<T>::value && std::is_base_of<Base, std::decay<Derived>>::value,
|
||||
decltype((std::forward<Derived>(ref).*pmf)(std::forward<Args>(args)...))> {
|
||||
return (std::forward<Derived>(ref).*pmf)(std::forward<Args>(args)...);
|
||||
@ -62,7 +62,7 @@ auto invoke_impl(T Base::*pmf, Derived &&ref,
|
||||
|
||||
template <class Base, class T, class RefWrap, class... Args>
|
||||
auto invoke_impl(T Base::*pmf, RefWrap &&ref,
|
||||
Args &&... args) noexcept(noexcept((ref.get().*pmf)(std::forward<Args>(args)...)))
|
||||
Args &&...args) noexcept(noexcept((ref.get().*pmf)(std::forward<Args>(args)...)))
|
||||
-> std::enable_if_t<std::is_function<T>::value && is_reference_wrapper<std::decay_t<RefWrap>>::value,
|
||||
decltype((ref.get().*pmf)(std::forward<Args>(args)...))>
|
||||
|
||||
@ -72,7 +72,7 @@ auto invoke_impl(T Base::*pmf, RefWrap &&ref,
|
||||
|
||||
template <class Base, class T, class Pointer, class... Args>
|
||||
auto invoke_impl(T Base::*pmf, Pointer &&ptr,
|
||||
Args &&... args) noexcept(noexcept(((*std::forward<Pointer>(ptr)).*pmf)(std::forward<Args>(args)...)))
|
||||
Args &&...args) noexcept(noexcept(((*std::forward<Pointer>(ptr)).*pmf)(std::forward<Args>(args)...)))
|
||||
-> std::enable_if_t<std::is_function<T>::value && !is_reference_wrapper<std::decay_t<Pointer>>::value &&
|
||||
!std::is_base_of<Base, std::decay_t<Pointer>>::value,
|
||||
decltype(((*std::forward<Pointer>(ptr)).*pmf)(std::forward<Args>(args)...))> {
|
||||
@ -102,7 +102,7 @@ auto invoke_impl(T Base::*pmd, Pointer &&ptr) noexcept(noexcept((*std::forward<P
|
||||
}
|
||||
|
||||
template <class F, class... Args>
|
||||
auto invoke_impl(F &&f, Args &&... args) noexcept(noexcept(std::forward<F>(f)(std::forward<Args>(args)...)))
|
||||
auto invoke_impl(F &&f, Args &&...args) noexcept(noexcept(std::forward<F>(f)(std::forward<Args>(args)...)))
|
||||
-> std::enable_if_t<!std::is_member_pointer<std::decay_t<F>>::value,
|
||||
decltype(std::forward<F>(f)(std::forward<Args>(args)...))> {
|
||||
return std::forward<F>(f)(std::forward<Args>(args)...);
|
||||
@ -110,7 +110,7 @@ auto invoke_impl(F &&f, Args &&... args) noexcept(noexcept(std::forward<F>(f)(st
|
||||
|
||||
template <class F, class... ArgTypes>
|
||||
auto invoke(F &&f,
|
||||
ArgTypes &&... args) noexcept(noexcept(invoke_impl(std::forward<F>(f), std::forward<ArgTypes>(args)...)))
|
||||
ArgTypes &&...args) noexcept(noexcept(invoke_impl(std::forward<F>(f), std::forward<ArgTypes>(args)...)))
|
||||
-> decltype(invoke_impl(std::forward<F>(f), std::forward<ArgTypes>(args)...)) {
|
||||
return invoke_impl(std::forward<F>(f), std::forward<ArgTypes>(args)...);
|
||||
}
|
||||
@ -176,29 +176,29 @@ void tuple_for_each(const std::tuple<Args...> &tuple, const F &func) {
|
||||
}
|
||||
|
||||
template <size_t N, class Arg, class... Args, std::enable_if_t<N == 0, int> = 0>
|
||||
auto &&get_nth_argument(Arg &&arg, Args &&... args) {
|
||||
auto &&get_nth_argument(Arg &&arg, Args &&...args) {
|
||||
return std::forward<Arg>(arg);
|
||||
}
|
||||
|
||||
template <size_t N, class Arg, class... Args, std::enable_if_t<N != 0, int> = 0>
|
||||
auto &&get_nth_argument(Arg &&arg, Args &&... args) {
|
||||
auto &&get_nth_argument(Arg &&arg, Args &&...args) {
|
||||
return get_nth_argument<N - 1>(std::forward<Args &&>(args)...);
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
auto &&get_last_argument(Args &&... args) {
|
||||
auto &&get_last_argument(Args &&...args) {
|
||||
return get_nth_argument<sizeof...(Args) - 1>(std::forward<Args &&>(args)...);
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
template <class F, class... Args, std::size_t... S>
|
||||
auto call_n_arguments_impl(IntSeq<S...>, F &&f, Args &&... args) {
|
||||
auto call_n_arguments_impl(IntSeq<S...>, F &&f, Args &&...args) {
|
||||
return f(get_nth_argument<S>(std::forward<Args>(args)...)...);
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
template <size_t N, class F, class... Args>
|
||||
auto call_n_arguments(F &&f, Args &&... args) {
|
||||
auto call_n_arguments(F &&f, Args &&...args) {
|
||||
return detail::call_n_arguments_impl(detail::IntRange<N>(), f, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ class optional {
|
||||
}
|
||||
|
||||
template <class... ArgsT>
|
||||
void emplace(ArgsT &&... args) {
|
||||
void emplace(ArgsT &&...args) {
|
||||
impl_.emplace(std::forward<ArgsT>(args)...);
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,8 @@
|
||||
|
||||
#define REF_NEW ref new
|
||||
#define CLRCALL
|
||||
#define DEPRECATED_ATTRIBUTE(message) ::Windows::Foundation::Metadata::Deprecated(message,\
|
||||
::Windows::Foundation::Metadata::DeprecationType::Deprecate, 0x0)
|
||||
#define DEPRECATED_ATTRIBUTE(message) \
|
||||
::Windows::Foundation::Metadata::Deprecated(message, ::Windows::Foundation::Metadata::DeprecationType::Deprecate, 0x0)
|
||||
|
||||
namespace CxCli {
|
||||
|
||||
@ -49,7 +49,7 @@ using Platform::NullReferenceException;
|
||||
|
||||
template <class Key, class Value>
|
||||
class ConcurrentDictionary {
|
||||
public:
|
||||
public:
|
||||
bool TryGetValue(Key key, Value &value) {
|
||||
std::lock_guard<std::mutex> guard(mutex_);
|
||||
auto it = impl_.find(key);
|
||||
@ -69,11 +69,12 @@ public:
|
||||
impl_.erase(it);
|
||||
return true;
|
||||
}
|
||||
Value &operator [] (Key key) {
|
||||
Value &operator[](Key key) {
|
||||
std::lock_guard<std::mutex> guard(mutex_);
|
||||
return impl_[key];
|
||||
}
|
||||
private:
|
||||
|
||||
private:
|
||||
std::mutex mutex_;
|
||||
std::map<Key, Value> impl_;
|
||||
};
|
||||
@ -82,7 +83,7 @@ inline std::int64_t Increment(volatile std::int64_t &value) {
|
||||
return InterlockedIncrement64(&value);
|
||||
}
|
||||
|
||||
inline std::string string_to_unmanaged(String^ str) {
|
||||
inline std::string string_to_unmanaged(String ^ str) {
|
||||
if (!str) {
|
||||
return std::string();
|
||||
}
|
||||
@ -93,12 +94,12 @@ inline std::string string_to_unmanaged(String^ str) {
|
||||
return r_unmanaged_str.move_as_ok();
|
||||
}
|
||||
|
||||
inline String^ string_from_unmanaged(const std::string &from) {
|
||||
inline String ^ string_from_unmanaged(const std::string &from) {
|
||||
auto tmp = td::to_wstring(from).ok();
|
||||
return REF_NEW String(tmp.c_str(), static_cast<unsigned>(tmp.size()));
|
||||
}
|
||||
|
||||
} // namespace CxCli
|
||||
} // namespace CxCli
|
||||
|
||||
#elif TD_CLI
|
||||
|
||||
@ -128,27 +129,27 @@ using System::NullReferenceException;
|
||||
|
||||
using System::Collections::Concurrent::ConcurrentDictionary;
|
||||
|
||||
inline std::int64_t Increment(std::int64_t %value) {
|
||||
inline std::int64_t Increment(std::int64_t % value) {
|
||||
return System::Threading::Interlocked::Increment(value);
|
||||
}
|
||||
|
||||
inline std::string string_to_unmanaged(String^ str) {
|
||||
inline std::string string_to_unmanaged(String ^ str) {
|
||||
if (!str || str->Length == 0) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
Array<System::Byte>^ bytes = System::Text::Encoding::UTF8->GetBytes(str);
|
||||
Array<System::Byte> ^ bytes = System::Text::Encoding::UTF8->GetBytes(str);
|
||||
cli::pin_ptr<System::Byte> pinned_ptr = &bytes[0];
|
||||
std::string result(reinterpret_cast<const char *>(&pinned_ptr[0]), bytes->Length);
|
||||
return result;
|
||||
}
|
||||
|
||||
inline String^ string_from_unmanaged(const std::string &from) {
|
||||
inline String ^ string_from_unmanaged(const std::string &from) {
|
||||
if (from.empty()) {
|
||||
return String::Empty;
|
||||
}
|
||||
|
||||
Array<System::Byte>^ bytes = REF_NEW Vector<System::Byte>(static_cast<ArrayIndexType>(from.size()));
|
||||
Array<System::Byte> ^ bytes = REF_NEW Vector<System::Byte>(static_cast<ArrayIndexType>(from.size()));
|
||||
cli::pin_ptr<System::Byte> pinned_ptr = &bytes[0];
|
||||
for (size_t i = 0; i < from.size(); ++i) {
|
||||
pinned_ptr[i] = from[i];
|
||||
@ -156,6 +157,6 @@ inline String^ string_from_unmanaged(const std::string &from) {
|
||||
return System::Text::Encoding::UTF8->GetString(bytes);
|
||||
}
|
||||
|
||||
} // namespace CxCli
|
||||
} // namespace CxCli
|
||||
|
||||
#endif
|
||||
|
@ -40,7 +40,7 @@ class ThreadPthread {
|
||||
return *this;
|
||||
}
|
||||
template <class Function, class... Args>
|
||||
explicit ThreadPthread(Function &&f, Args &&... args) {
|
||||
explicit ThreadPthread(Function &&f, Args &&...args) {
|
||||
auto func = create_destructor([args = std::make_tuple(decay_copy(std::forward<Function>(f)),
|
||||
decay_copy(std::forward<Args>(args))...)]() mutable {
|
||||
invoke_tuple(std::move(args));
|
||||
|
@ -34,7 +34,7 @@ class ThreadStl {
|
||||
join();
|
||||
}
|
||||
template <class Function, class... Args>
|
||||
explicit ThreadStl(Function &&f, Args &&... args) {
|
||||
explicit ThreadStl(Function &&f, Args &&...args) {
|
||||
thread_ = std::thread([args = std::make_tuple(decay_copy(std::forward<Function>(f)),
|
||||
decay_copy(std::forward<Args>(args))...)]() mutable {
|
||||
ThreadIdGuard thread_id_guard;
|
||||
|
@ -29,7 +29,7 @@ namespace td {
|
||||
|
||||
// If raw_ptr is not nullptr, allocate T as in std::make_unique<T>(args...) and store pointer into raw_ptr
|
||||
template <class T, class P, class... ArgsT>
|
||||
bool init_thread_local(P &raw_ptr, ArgsT &&... args);
|
||||
bool init_thread_local(P &raw_ptr, ArgsT &&...args);
|
||||
|
||||
// Destroy all thread locals, and store nullptr into corresponding pointers
|
||||
void clear_thread_locals();
|
||||
@ -42,7 +42,7 @@ namespace detail {
|
||||
void add_thread_local_destructor(unique_ptr<Destructor> destructor);
|
||||
|
||||
template <class T, class P, class... ArgsT>
|
||||
void do_init_thread_local(P &raw_ptr, ArgsT &&... args) {
|
||||
void do_init_thread_local(P &raw_ptr, ArgsT &&...args) {
|
||||
auto ptr = std::make_unique<T>(std::forward<ArgsT>(args)...);
|
||||
raw_ptr = ptr.get();
|
||||
|
||||
@ -54,7 +54,7 @@ void do_init_thread_local(P &raw_ptr, ArgsT &&... args) {
|
||||
} // namespace detail
|
||||
|
||||
template <class T, class P, class... ArgsT>
|
||||
bool init_thread_local(P &raw_ptr, ArgsT &&... args) {
|
||||
bool init_thread_local(P &raw_ptr, ArgsT &&...args) {
|
||||
if (likely(raw_ptr != nullptr)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ bool operator!=(const unique_ptr<T> &p, std::nullptr_t) {
|
||||
}
|
||||
|
||||
template <class Type, class... Args>
|
||||
unique_ptr<Type> make_unique(Args &&... args) {
|
||||
unique_ptr<Type> make_unique(Args &&...args) {
|
||||
return unique_ptr<Type>(new Type(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user