Commit 53f4dacb authored by Dominik Charousset's avatar Dominik Charousset

Coding style: no more `using namespace std`

parent 22f1a137
......@@ -25,7 +25,10 @@
#include "caf/all.hpp"
#include "caf/io/all.hpp"
using namespace std;
using std::cout;
using std::cerr;
using std::endl;
using namespace caf;
using namespace caf::io;
......@@ -35,13 +38,13 @@ using kickoff_atom = atom_constant<atom("kickoff")>;
// utility function to print an exit message with custom name
void print_on_exit(const actor& ptr, const std::string& name) {
ptr->attach_functor([=](std::uint32_t reason) {
ptr->attach_functor([=](uint32_t reason) {
aout(ptr) << name << " exited with reason " << reason << endl;
});
}
behavior ping(event_based_actor* self, size_t num_pings) {
auto count = make_shared<size_t>(0);
auto count = std::make_shared<size_t>(0);
return {
[=](kickoff_atom, const actor& pong) {
self->send(pong, ping_atom::value, int32_t(1));
......@@ -149,7 +152,8 @@ behavior broker_impl(broker* self, connection_handle hdl, const actor& buddy) {
self->send(buddy, atm, ival);
},
others >> [=] {
cout << "unexpected: " << to_string(self->current_message()) << endl;
aout(self) << "unexpected: "
<< to_string(self->current_message()) << endl;
}
};
}
......@@ -167,7 +171,8 @@ behavior server(broker* self, const actor& buddy) {
self->quit();
},
others >> [=] {
cout << "unexpected: " << to_string(self->current_message()) << endl;
aout(self) << "unexpected: "
<< to_string(self->current_message()) << endl;
}
};
}
......@@ -177,6 +182,7 @@ optional<uint16_t> as_u16(const std::string& str) {
}
int main(int argc, char** argv) {
using std::string;
message_builder{argv + 1, argv + argc}.apply({
on("-s", as_u16) >> [&](uint16_t port) {
cout << "run in server mode" << endl;
......
......@@ -3,7 +3,9 @@
#include "caf/all.hpp"
using namespace std;
using std::endl;
using std::string;
using namespace caf;
behavior mirror(event_based_actor* self) {
......
......@@ -11,9 +11,11 @@
#include "caf/all.hpp"
using std::cout;
using std::cerr;
using std::endl;
using std::chrono::seconds;
using namespace std;
using namespace caf;
namespace {
......
......@@ -29,8 +29,6 @@
#include "caf/detail/singletons.hpp"
using namespace std;
namespace caf {
actor_proxy::anchor::anchor(actor_proxy* instance) : m_ptr(instance) {
......
......@@ -23,8 +23,6 @@
#include "caf/local_actor.hpp"
#include "caf/detail/behavior_stack.hpp"
using namespace std;
namespace caf {
namespace detail {
......
......@@ -25,8 +25,6 @@
#include "caf/detail/logging.hpp"
using namespace std;
namespace caf {
forwarding_actor_proxy::forwarding_actor_proxy(actor_id aid, node_id nid,
......
......@@ -51,7 +51,7 @@ std::vector<iface_info> get_mac_addresses() {
auto ifm = reinterpret_cast<if_msghdr*>(buf.get());
auto sdl = reinterpret_cast<sockaddr_dl*>(ifm + 1);
auto ptr = reinterpret_cast<unsigned char*>(LLADDR(sdl));
auto uctoi = [](unsigned char c)->unsigned {
auto uctoi = [](unsigned char c) -> unsigned {
return static_cast<unsigned char>(c);
};
std::ostringstream oss;
......@@ -95,8 +95,6 @@ std::vector<iface_info> get_mac_addresses() {
#include <unistd.h>
#include <iostream>
using namespace std;
namespace caf {
namespace detail {
......@@ -116,8 +114,8 @@ std::vector<iface_info> get_mac_addresses() {
perror("ioctl(SIOCGIFCONF)");
return {};
}
vector<iface_info> result;
auto ctoi = [](char c)->unsigned {
std::vector<iface_info> result;
auto ctoi = [](char c) -> unsigned {
return static_cast<unsigned char>(c);
};
// iterate through interfaces
......@@ -187,14 +185,12 @@ struct c_free {
} // namespace <anonymous>
using namespace std;
namespace caf {
namespace detail {
std::vector<iface_info> get_mac_addresses() {
// result vector
vector<iface_info> result;
std::vector<iface_info> result;
// flags to pass to GetAdaptersAddresses
ULONG flags = GAA_FLAG_INCLUDE_PREFIX;
// default to unspecified address family (both)
......
......@@ -153,8 +153,6 @@ std::string get_root_uuid() {
#include <windows.h>
#include <tchar.h>
using namespace std;
namespace caf {
namespace detail {
......@@ -163,7 +161,9 @@ constexpr size_t max_drive_name = MAX_PATH;
}
// if TCHAR is indeed a char, we can simply move rhs
void mv(std::string& lhs, std::string&& rhs) { lhs = std::move(rhs); }
void mv(std::string& lhs, std::string&& rhs) {
lhs = std::move(rhs);
}
// if TCHAR is defined as WCHAR, we have to do unicode conversion
void mv(std::string& lhs, const std::basic_string<WCHAR>& rhs) {
......@@ -194,12 +194,13 @@ std::string get_root_uuid() {
mv(uuid, drive_name.substr(first, last - first));
// UUIDs are formatted as 8-4-4-4-12 hex digits groups
auto cpy = uuid;
replace_if(cpy.begin(), cpy.end(), ::isxdigit, 'F');
std::replace_if(cpy.begin(), cpy.end(), ::isxdigit, 'F');
// discard invalid UUID
if (cpy != uuid_format)
if (cpy != uuid_format) {
uuid.clear();
else
} else {
return uuid; // return first valid UUID we get
}
}
}
}
......
......@@ -24,8 +24,6 @@
#include "caf/mailbox_element.hpp"
using namespace std;
#ifdef CAF_NO_MEM_MANAGEMENT
int caf_memory_keep_compiler_happy() {
......@@ -50,7 +48,7 @@ memory_cache::~memory_cache() {
// nop
}
using cache_map = map<const type_info*, unique_ptr<memory_cache>>;
using cache_map = std::map<const std::type_info*,std::unique_ptr<memory_cache>>;
void cache_map_destructor(void* ptr) {
delete reinterpret_cast<cache_map*>(ptr);
......@@ -67,13 +65,13 @@ cache_map& get_cache_map() {
cache = new cache_map;
pthread_setspecific(s_key, cache);
// insert default types
unique_ptr<memory_cache> tmp(new basic_memory_cache<mailbox_element>);
cache->insert(make_pair(&typeid(mailbox_element), move(tmp)));
std::unique_ptr<memory_cache> tmp(new basic_memory_cache<mailbox_element>);
cache->insert(std::make_pair(&typeid(mailbox_element), move(tmp)));
}
return *cache;
}
memory_cache* memory::get_cache_map_entry(const type_info* tinf) {
memory_cache* memory::get_cache_map_entry(const std::type_info* tinf) {
auto& cache = get_cache_map();
auto i = cache.find(tinf);
if (i != cache.end()) {
......@@ -82,7 +80,7 @@ memory_cache* memory::get_cache_map_entry(const type_info* tinf) {
return nullptr;
}
void memory::add_cache_map_entry(const type_info* tinf,
void memory::add_cache_map_entry(const std::type_info* tinf,
memory_cache* instance) {
auto& cache = get_cache_map();
cache[tinf].reset(instance);
......
......@@ -477,7 +477,6 @@ namespace network {
CAF_LOGF_TRACE("fd = " << e.fd
<< ", old mask = " << (e.ptr ? e.ptr->eventbf() : -1)
<< ", new mask = " << e.mask);
using namespace std;
auto last = m_pollset.end();
auto i = std::lower_bound(m_pollset.begin(), last, e.fd,
[](const pollfd& lhs, int rhs) {
......
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