Commit 03e2d174 authored by neverlord's avatar neverlord

use nullptr (GCC 4.6 update)

parent a21f0ac6
CXX = /opt/local/bin/g++-mp-4.5 CXX = /opt/local/bin/g++-mp-4.6
CXXFLAGS = -std=c++0x -pedantic -Wall -Wextra -O2 -I/opt/local/include/ CXXFLAGS = -std=c++0x -pedantic -Wall -Wextra -O2 -I/opt/local/include/
#CXXFLAGS = -std=c++0x -pedantic -Wall -Wextra -g -O0 -I/opt/local/include/ #CXXFLAGS = -std=c++0x -pedantic -Wall -Wextra -g -O0 -I/opt/local/include/
LIBS = -L/opt/local/lib -lboost_thread-mt LIBS = -L/opt/local/lib -lboost_thread-mt
...@@ -60,15 +60,15 @@ ...@@ -60,15 +60,15 @@
<valuemap type="QVariantMap"> <valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">all</value> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">all</value>
<valuelist key="abstractProcess.Environment" type="QVariantList"> <valuelist key="abstractProcess.Environment" type="QVariantList">
<value type="QString">Apple_PubSub_Socket_Render=/tmp/launch-tO8Wwx/Render</value> <value type="QString">Apple_PubSub_Socket_Render=/tmp/launch-qTxq6l/Render</value>
<value type="QString">COMMAND_MODE=unix2003</value> <value type="QString">COMMAND_MODE=unix2003</value>
<value type="QString">DISPLAY=/tmp/launch-w1qNYf/org.x:0</value> <value type="QString">DISPLAY=/tmp/launch-b33dXE/org.x:0</value>
<value type="QString">HOME=/Users/neverlord</value> <value type="QString">HOME=/Users/neverlord</value>
<value type="QString">LOGNAME=neverlord</value> <value type="QString">LOGNAME=neverlord</value>
<value type="QString">PATH=/usr/bin:/bin:/usr/sbin:/sbin</value> <value type="QString">PATH=/usr/bin:/bin:/usr/sbin:/sbin</value>
<value type="QString">SHELL=/bin/bash</value> <value type="QString">SHELL=/bin/bash</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/launch-dnUZas/Listeners</value> <value type="QString">SSH_AUTH_SOCK=/tmp/launch-ZcReR3/Listeners</value>
<value type="QString">TMPDIR=/var/folders/SE/SEReyCW0H-yDPCnNCe8mN++++TI/-Tmp-/</value> <value type="QString">TMPDIR=/var/folders/1p/1p6iuPgbH7GoDkrjrT20tU+++TI/-Tmp-/</value>
<value type="QString">USER=neverlord</value> <value type="QString">USER=neverlord</value>
<value type="QString">__CF_USER_TEXT_ENCODING=0x1F5:0:3</value> <value type="QString">__CF_USER_TEXT_ENCODING=0x1F5:0:3</value>
</valuelist> </valuelist>
......
...@@ -23,7 +23,6 @@ cppa/util/utype_iterator.hpp ...@@ -23,7 +23,6 @@ cppa/util/utype_iterator.hpp
cppa/detail/matcher.hpp cppa/detail/matcher.hpp
cppa/detail/tuple_vals.hpp cppa/detail/tuple_vals.hpp
cppa/match.hpp cppa/match.hpp
src/decorated_tuple.cpp
cppa/detail/decorated_tuple.hpp cppa/detail/decorated_tuple.hpp
cppa/cow_ptr.hpp cppa/cow_ptr.hpp
cppa/util/detach.hpp cppa/util/detach.hpp
...@@ -107,3 +106,4 @@ queue_performances/blocking_cached_stack2.hpp ...@@ -107,3 +106,4 @@ queue_performances/blocking_cached_stack2.hpp
queue_performances/blocking_sutter_list.hpp queue_performances/blocking_sutter_list.hpp
queue_performances/lockfree_list.hpp queue_performances/lockfree_list.hpp
queue_performances/intrusive_sutter_list.hpp queue_performances/intrusive_sutter_list.hpp
cppa/detail/cpp0x_thread_wrapper.hpp
/Users/neverlord/libcppa /Users/neverlord/libcppa
/opt/local/include/gcc45/c++ /opt/local/include/gcc46/c++
/opt/local/include/
/Users/neverlord/libcppa/unit_testing /Users/neverlord/libcppa/unit_testing
...@@ -68,7 +68,7 @@ class cow_ptr ...@@ -68,7 +68,7 @@ class cow_ptr
const T& operator*() const { return *m_ptr.get(); } const T& operator*() const { return *m_ptr.get(); }
explicit operator bool() const { return m_ptr.get() != 0; } explicit operator bool() const { return m_ptr.get() != nullptr; }
}; };
......
#ifndef CPPA_DETAIL_CPP0X_THREAD_WRAPPER_HPP
#define CPPA_DETAIL_CPP0X_THREAD_WRAPPER_HPP
#include <boost/thread.hpp>
namespace std {
using boost::mutex;
using boost::recursive_mutex;
using boost::timed_mutex;
using boost::recursive_timed_mutex;
using boost::adopt_lock;
using boost::defer_lock;
using boost::try_to_lock;
using boost::lock_guard;
using boost::unique_lock;
} // namespace std
#endif // CPPA_DETAIL_CPP0X_THREAD_WRAPPER_HPP
...@@ -15,7 +15,7 @@ struct matcher<Head, Tail...> ...@@ -15,7 +15,7 @@ struct matcher<Head, Tail...>
{ {
static bool match(util::utype_iterator& begin, static bool match(util::utype_iterator& begin,
util::utype_iterator& end, util::utype_iterator& end,
std::vector<std::size_t>* res = 0, std::vector<std::size_t>* res = nullptr,
std::size_t pos = 0) std::size_t pos = 0)
{ {
if (begin != end) if (begin != end)
...@@ -40,7 +40,7 @@ struct matcher<any_type, Tail...> ...@@ -40,7 +40,7 @@ struct matcher<any_type, Tail...>
{ {
static bool match(util::utype_iterator &begin, static bool match(util::utype_iterator &begin,
util::utype_iterator &end, util::utype_iterator &end,
std::vector<std::size_t>* res = 0, std::vector<std::size_t>* res = nullptr,
std::size_t pos = 0) std::size_t pos = 0)
{ {
if (begin != end) if (begin != end)
...@@ -58,14 +58,14 @@ struct matcher<any_type*, Next, Tail...> ...@@ -58,14 +58,14 @@ struct matcher<any_type*, Next, Tail...>
{ {
static bool match(util::utype_iterator &begin, static bool match(util::utype_iterator &begin,
util::utype_iterator &end, util::utype_iterator &end,
std::vector<std::size_t>* res = 0, std::vector<std::size_t>* res = nullptr,
std::size_t pos = 0) std::size_t pos = 0)
{ {
bool result = false; bool result = false;
while (!result) while (!result)
{ {
util::utype_iterator begin_cpy = begin; util::utype_iterator begin_cpy = begin;
result = matcher<Next, Tail...>::match(begin_cpy, end, 0, pos); result = matcher<Next, Tail...>::match(begin_cpy,end,nullptr,pos);
if (!result) if (!result)
{ {
++begin; ++begin;
...@@ -88,7 +88,7 @@ struct matcher<any_type*> ...@@ -88,7 +88,7 @@ struct matcher<any_type*>
{ {
static bool match(util::utype_iterator&, static bool match(util::utype_iterator&,
util::utype_iterator&, util::utype_iterator&,
std::vector<std::size_t>* = 0, std::vector<std::size_t>* = nullptr,
std::size_t = 0) std::size_t = 0)
{ {
return true; return true;
...@@ -100,7 +100,7 @@ struct matcher<> ...@@ -100,7 +100,7 @@ struct matcher<>
{ {
static bool match(util::utype_iterator& begin, static bool match(util::utype_iterator& begin,
util::utype_iterator& end, util::utype_iterator& end,
std::vector<std::size_t>* = 0, std::vector<std::size_t>* = nullptr,
std::size_t = 0) std::size_t = 0)
{ {
return begin == end; return begin == end;
......
...@@ -14,6 +14,7 @@ std::string demangle(const char*); ...@@ -14,6 +14,7 @@ std::string demangle(const char*);
std::map<std::string, utype*>& uniform_types(); std::map<std::string, utype*>& uniform_types();
// default implementation of utype
template<typename T> template<typename T>
class utype_impl : public utype class utype_impl : public utype
{ {
......
...@@ -70,7 +70,7 @@ class intrusive_ptr : detail::comparable<intrusive_ptr<T>, T*>, ...@@ -70,7 +70,7 @@ class intrusive_ptr : detail::comparable<intrusive_ptr<T>, T*>,
std::swap(m_ptr, other.m_ptr); std::swap(m_ptr, other.m_ptr);
} }
void reset(T* new_value = 0) void reset(T* new_value = nullptr)
{ {
if (m_ptr && !m_ptr->deref()) delete m_ptr; if (m_ptr && !m_ptr->deref()) delete m_ptr;
set_ptr(new_value); set_ptr(new_value);
...@@ -112,7 +112,7 @@ class intrusive_ptr : detail::comparable<intrusive_ptr<T>, T*>, ...@@ -112,7 +112,7 @@ class intrusive_ptr : detail::comparable<intrusive_ptr<T>, T*>,
static_assert(std::is_convertible<Y*, T*>::value, static_assert(std::is_convertible<Y*, T*>::value,
"Y* is not assignable to T*"); "Y* is not assignable to T*");
m_ptr = other.m_ptr; m_ptr = other.m_ptr;
other.m_ptr = 0; other.m_ptr = nullptr;
return *this; return *this;
} }
...@@ -124,7 +124,7 @@ class intrusive_ptr : detail::comparable<intrusive_ptr<T>, T*>, ...@@ -124,7 +124,7 @@ class intrusive_ptr : detail::comparable<intrusive_ptr<T>, T*>,
const T& operator*() const { return *m_ptr; } const T& operator*() const { return *m_ptr; }
inline explicit operator bool() const { return m_ptr != 0; } inline explicit operator bool() const { return m_ptr != nullptr; }
inline ptrdiff_t compare(const T* ptr) const inline ptrdiff_t compare(const T* ptr) const
{ {
......
...@@ -20,6 +20,12 @@ struct invoke_rules ...@@ -20,6 +20,12 @@ struct invoke_rules
invoke_rules() { } invoke_rules() { }
// equal to the move constructor
invoke_rules(invoke_rules& other) : m_list(std::move(other.m_list))
{
other.m_list.clear();
}
invoke_rules(invoke_rules&& other) : m_list(std::move(other.m_list)) invoke_rules(invoke_rules&& other) : m_list(std::move(other.m_list))
{ {
other.m_list.clear(); other.m_list.clear();
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
#include "cppa/channel.hpp" #include "cppa/channel.hpp"
// forward declaration
namespace cppa { class invoke_rules; }
namespace cppa { namespace cppa {
class message_queue // forward declaration
class invoke_rules;
class message_queue : public channel
{ {
public: public:
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
namespace cppa { namespace cppa {
/** /**
* @brief Get the uniform type information for @p T. * @brief Get the uniform type information ({@link utype}) for @p T.
*/ */
template<typename T> template<typename T>
const utype& uniform_type_info() const utype& uniform_type_info()
...@@ -26,8 +26,8 @@ const utype& uniform_type_info() ...@@ -26,8 +26,8 @@ const utype& uniform_type_info()
} }
/** /**
* @brief Get the uniform type information associated with the name * @brief Get the uniform type information ({@link utype}) associated with
* @p uniform_type_name. * the name @p uniform_type_name.
*/ */
const utype& uniform_type_info(const std::string& uniform_type_name); const utype& uniform_type_info(const std::string& uniform_type_name);
...@@ -48,20 +48,4 @@ const utype& uniform_type_info(const std::string& uniform_type_name); ...@@ -48,20 +48,4 @@ const utype& uniform_type_info(const std::string& uniform_type_name);
= cppa::detail::utype_impl< what >::instance.announce_helper() = cppa::detail::utype_impl< what >::instance.announce_helper()
#endif #endif
/*
CPPA_ANNOUNCE(char);
CPPA_ANNOUNCE(std::int8_t);
CPPA_ANNOUNCE(std::uint8_t);
CPPA_ANNOUNCE(std::int16_t);
CPPA_ANNOUNCE(std::uint16_t);
CPPA_ANNOUNCE(std::int32_t);
CPPA_ANNOUNCE(std::uint32_t);
CPPA_ANNOUNCE(std::int64_t);
CPPA_ANNOUNCE(std::uint64_t);
CPPA_ANNOUNCE(float);
CPPA_ANNOUNCE(double);
CPPA_ANNOUNCE(long double);
CPPA_ANNOUNCE(std::string);
*/
#endif // UNIFORM_TYPE_INFO_HPP #endif // UNIFORM_TYPE_INFO_HPP
...@@ -19,15 +19,18 @@ class is_comparable ...@@ -19,15 +19,18 @@ class is_comparable
template<typename A, typename B> template<typename A, typename B>
static bool cmp_help_fun(const A* arg0, const B* arg1, static bool cmp_help_fun(const A* arg0, const B* arg1,
decltype(*arg0 == *arg1)* = 0) decltype(*arg0 == *arg1)* = nullptr)
{ {
return true; return true;
} }
template<typename A, typename B> template<typename A, typename B>
static void cmp_help_fun(const A*, const B*, void* = 0) { } static void cmp_help_fun(const A*, const B*, void* = nullptr) { }
typedef decltype(cmp_help_fun((T1*) 0, (T2*) 0, (bool*) 0)) result_type; typedef decltype(cmp_help_fun(static_cast<T1*>(nullptr),
static_cast<T2*>(nullptr),
static_cast<bool*>(nullptr)))
result_type;
public: public:
......
...@@ -10,15 +10,17 @@ class is_copyable_ ...@@ -10,15 +10,17 @@ class is_copyable_
{ {
template<typename A> template<typename A>
static bool cpy_help_fun(const A* arg0, decltype(new A(*arg0)) = 0) static bool cpy_help_fun(const A* arg0, decltype(new A(*arg0)) = nullptr)
{ {
return true; return true;
} }
template<typename A> template<typename A>
static void cpy_help_fun(const A*, void* = 0) { } static void cpy_help_fun(const A*, void* = nullptr) { }
typedef decltype(cpy_help_fun((T*) 0, (T*) 0)) result_type; typedef decltype(cpy_help_fun(static_cast<T*>(nullptr),
static_cast<T*>(nullptr)))
result_type;
public: public:
......
...@@ -113,8 +113,7 @@ class single_reader_queue ...@@ -113,8 +113,7 @@ class single_reader_queue
private: private:
// exposed to "outside" access // exposed to "outside" access
std::atomic<element_type*> m_tail;
atomic<element_type*> m_tail;
// accessed only by the owner // accessed only by the owner
element_type* m_head; element_type* m_head;
......
...@@ -56,7 +56,6 @@ HEADERS = cppa/actor.hpp \ ...@@ -56,7 +56,6 @@ HEADERS = cppa/actor.hpp \
SOURCES = src/actor_behavior.cpp \ SOURCES = src/actor_behavior.cpp \
src/channel.cpp \ src/channel.cpp \
src/decorated_tuple.cpp \
src/deserializer.cpp \ src/deserializer.cpp \
src/group.cpp \ src/group.cpp \
src/mock_scheduler.cpp \ src/mock_scheduler.cpp \
......
#include <stdexcept>
#include "cppa/detail/decorated_tuple.hpp"
/*
namespace cppa { namespace detail {
decorated_tuple::decorated_tuple(const decorated_tuple::ptr_type& d,
const std::vector<std::size_t>& v,
util::abstract_type_list* tlist)
: m_decorated(d), m_mappings(v), m_types(tlist)
{
if (!tlist)
{
throw std::invalid_argument("tlist == nullpr");
}
}
decorated_tuple::decorated_tuple(const decorated_tuple& other)
: abstract_tuple()
, m_decorated(other.m_decorated)
, m_mappings(other.m_mappings)
, m_types(other.m_types->copy())
{
}
decorated_tuple::~decorated_tuple()
{
delete m_types;
}
void* decorated_tuple::mutable_at(std::size_t pos)
{
return m_decorated->mutable_at(m_mappings[pos]);
}
std::size_t decorated_tuple::size() const
{
return m_mappings.size();
}
decorated_tuple* decorated_tuple::copy() const
{
return new decorated_tuple(*this);
}
const void* decorated_tuple::at(std::size_t pos) const
{
return m_decorated->at(m_mappings[pos]);
}
const utype& decorated_tuple::utype_at(std::size_t pos) const
{
return m_decorated->utype_at(m_mappings[pos]);
}
const util::abstract_type_list& decorated_tuple::types() const
{
return *m_types;
// throw std::runtime_error("not implemented yet");
}
bool decorated_tuple::equal_to(const abstract_tuple&) const
{
return false;
}
} } // namespace cppa::detail
*/
...@@ -11,7 +11,7 @@ deserializer::deserializer(const intrusive_ptr<util::source>& src) : m_src(src) ...@@ -11,7 +11,7 @@ deserializer::deserializer(const intrusive_ptr<util::source>& src) : m_src(src)
} // namespace cppa } // namespace cppa
cppa::deserializer& operator>>(cppa::deserializer& d, cppa::actor_ptr& aptr) cppa::deserializer& operator>>(cppa::deserializer& d, cppa::actor_ptr&)
{ {
return d; return d;
} }
......
#include <set> #include <set>
#include <map> #include <map>
#ifdef __APPLE__
#include "cppa/detail/cpp0x_thread_wrapper.hpp"
#else
#include <thread>
#endif
// for thread_specific_ptr
// needed unless the new keyword "thread_local" works in GCC
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include "cppa/message.hpp" #include "cppa/message.hpp"
...@@ -103,7 +111,7 @@ struct actor_impl : context ...@@ -103,7 +111,7 @@ struct actor_impl : context
mbox m_mbox; mbox m_mbox;
actor_impl(actor_behavior* b = 0) : m_behavior(b), m_exited(false) { } actor_impl(actor_behavior* b = nullptr) : m_behavior(b), m_exited(false) { }
~actor_impl() ~actor_impl()
{ {
......
...@@ -11,7 +11,7 @@ serializer::serializer(const intrusive_ptr<util::sink>& dsink) : m_sink(dsink) ...@@ -11,7 +11,7 @@ serializer::serializer(const intrusive_ptr<util::sink>& dsink) : m_sink(dsink)
} // namespace cppa } // namespace cppa
cppa::serializer& operator<<(cppa::serializer& s, const cppa::actor_ptr& aptr) cppa::serializer& operator<<(cppa::serializer& s, const cppa::actor_ptr&)
{ {
return s; return s;
} }
......
...@@ -78,7 +78,7 @@ struct int_helper<8, false> ...@@ -78,7 +78,7 @@ struct int_helper<8, false>
template<typename T> template<typename T>
struct uniform_int : int_helper<sizeof(T), std::numeric_limits<T>::is_signed>{}; struct uniform_int : int_helper<sizeof(T), std::numeric_limits<T>::is_signed>{};
std::map<std::string, cppa::utype*>* ut_map = 0; std::map<std::string, cppa::utype*>* ut_map = nullptr;
#ifdef CPPA_GCC #ifdef CPPA_GCC
template<typename T> template<typename T>
...@@ -95,14 +95,12 @@ std::string raw_name() ...@@ -95,14 +95,12 @@ std::string raw_name()
} }
#elif defined(CPPA_WINDOWS) #elif defined(CPPA_WINDOWS)
template<typename T> template<typename T>
const char* raw_name() inline const char* raw_name()
{ {
return typeid(T).name(); return typeid(T).name();
} }
#endif #endif
//string_map* btm_ptr = 0;
std::unique_ptr<string_map> btm_ptr; std::unique_ptr<string_map> btm_ptr;
const string_map& builtin_type_mappings() const string_map& builtin_type_mappings()
...@@ -215,6 +213,7 @@ std::string demangle_impl(const char* begin, const char* end, size_t size) ...@@ -215,6 +213,7 @@ std::string demangle_impl(const char* begin, const char* end, size_t size)
break; break;
case ' ': case ' ':
// the VC++ compiler adds "class" and "struct" before type names
if (tmp == "class" || tmp == "struct") if (tmp == "class" || tmp == "struct")
{ {
tmp.clear(); tmp.clear();
...@@ -243,7 +242,7 @@ std::string demangle(const char* decorated_type_name) ...@@ -243,7 +242,7 @@ std::string demangle(const char* decorated_type_name)
std::vector<std::string> needles; std::vector<std::string> needles;
needles.push_back("class "); needles.push_back("class ");
needles.push_back("struct "); needles.push_back("struct ");
// the VC++ compiler adds "class " and "struct " before a type names // the VC++ compiler adds "class " and "struct " before type names
for (size_t i = 0; i < needles.size(); ++i) for (size_t i = 0; i < needles.size(); ++i)
{ {
const std::string& needle = needles[i]; const std::string& needle = needles[i];
......
...@@ -210,7 +210,7 @@ std::size_t test__tuple() ...@@ -210,7 +210,7 @@ std::size_t test__tuple()
reset_invoke_states(); reset_invoke_states();
{ {
any_type* x = 0; any_type* x = nullptr;
CPPA_CHECK(x == any_val); CPPA_CHECK(x == any_val);
CPPA_CHECK(any_val == x); CPPA_CHECK(any_val == x);
CPPA_CHECK(any_val == 42); CPPA_CHECK(any_val == 42);
......
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