Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge commit 'cb9fae56dba242bee8a50915f462255a2546521e'

  • Loading branch information...
commit ca3e1d234513c5453fbfd044f9d20a0fbd057370 2 parents a726e9e + cb9fae5
@Bromeon authored
View
12 extlibs/aurora/include/Aurora/Config.hpp
@@ -29,18 +29,6 @@
#ifndef AURORA_CONFIG_HPP
#define AURORA_CONFIG_HPP
-// Compiler-dependent include path for TR1 headers
-// If your standard library isn't covered by this macro, please inform me.
-#ifdef _MSC_VER
- #define AURORA_TR1_HEADER(Header) <Header>
-#else
- #define AURORA_TR1_HEADER(Header) <tr1/Header>
-#endif // _MSC_VER
-
-
-// C++11 support
-// Define AURORA_HAS_CPP11 to activate C++11 features.
-
// Version of the library
#define AURORA_VERSION_MAJOR 1
View
2  extlibs/aurora/include/Aurora/Dispatch/Detail/BinaryFunction.hpp
@@ -46,7 +46,7 @@ namespace detail
};
- // Concrete caller class for global functions and function objects (like std::tr1::function)
+ // Concrete caller class for global functions and function objects (like std::function)
// B: Base class of dispatched hierarchy
// D1: Derived class of dispatched hierarchy (1st parameter)
// D2: Derived class of dispatched hierarchy (2nd parameter)
View
2  extlibs/aurora/include/Aurora/Dispatch/Detail/RttiImpl.hpp
@@ -44,7 +44,7 @@ namespace detail
{
explicit RttiClassNode(TypeInfo type)
: type(type)
- , base(NULL)
+ , base(nullptr)
{
}
View
2  extlibs/aurora/include/Aurora/Dispatch/Detail/UnaryFunction.hpp
@@ -46,7 +46,7 @@ namespace detail
};
- // Concrete caller class for global functions and function objects (like std::tr1::function)
+ // Concrete caller class for global functions and function objects (like std::function)
// B: Base class of dispatched hierarchy
// D: Derived class of dispatched hierarchy
// Fn: Function type
View
9 extlibs/aurora/include/Aurora/Dispatch/DoubleDispatcher.hpp
@@ -37,7 +37,7 @@
#include <Aurora/Tools/Exceptions.hpp>
#include <Aurora/Tools/ForEach.hpp>
#include <Aurora/Tools/TypeInfo.hpp>
-#include <Aurora/Tools/Detail/Metaprogramming.hpp>
+#include <Aurora/Tools/Metaprogramming.hpp>
#include <Aurora/Config.hpp>
#include <vector>
@@ -68,9 +68,10 @@ class DoubleDispatcher : private NonCopyable
// Static assertions
// Make sure that B is either T* or T&, where T is a polymorphic base class (containing virtual functions).
- AURORA_STATIC_ASSERT(
- std::tr1::is_pointer<B>::value && std::tr1::is_polymorphic< typename std::tr1::remove_pointer<B>::type >::value
- || std::tr1::is_reference<B>::value && std::tr1::is_polymorphic< typename std::tr1::remove_reference<B>::type >::value )
+ static_assert(
+ std::is_pointer<B>::value && std::is_polymorphic< typename std::remove_pointer<B>::type >::value
+ || std::is_lvalue_reference<B>::value && std::is_polymorphic< typename std::remove_reference<B>::type >::value,
+ "Template argument B must be a pointer or reference to a polymorphic base class.");
// ---------------------------------------------------------------------------------------------------------------------------
View
9 extlibs/aurora/include/Aurora/Dispatch/SingleDispatcher.hpp
@@ -37,7 +37,7 @@
#include <Aurora/Tools/TypeInfo.hpp>
#include <Aurora/Tools/Exceptions.hpp>
#include <Aurora/Tools/ForEach.hpp>
-#include <Aurora/Tools/Detail/Metaprogramming.hpp>
+#include <Aurora/Tools/Metaprogramming.hpp>
#include <Aurora/Config.hpp>
#include <vector>
@@ -68,9 +68,10 @@ class SingleDispatcher : private NonCopyable
// Static assertions
// Make sure that B is either T* or T&, where T is a polymorphic base class (containing virtual functions).
- AURORA_STATIC_ASSERT(
- std::tr1::is_pointer<B>::value && std::tr1::is_polymorphic< typename std::tr1::remove_pointer<B>::type >::value
- || std::tr1::is_reference<B>::value && std::tr1::is_polymorphic< typename std::tr1::remove_reference<B>::type >::value )
+ static_assert(
+ std::is_pointer<B>::value && std::is_polymorphic< typename std::remove_pointer<B>::type >::value
+ || std::is_lvalue_reference<B>::value && std::is_polymorphic< typename std::remove_reference<B>::type >::value,
+ "Template argument B must be a pointer or reference to a polymorphic base class.");
// ---------------------------------------------------------------------------------------------------------------------------
View
38 extlibs/aurora/include/Aurora/SmartPtr/CopiedPtr.hpp
@@ -34,9 +34,9 @@
#include <Aurora/Tools/SafeBool.hpp>
#include <Aurora/Config.hpp>
-#include <cstddef>
#include <algorithm>
-#include AURORA_TR1_HEADER(type_traits)
+#include <type_traits>
+
namespace aur
{
@@ -59,13 +59,13 @@ class CopiedPtr
/// @brief Default constructor
/// @details Initializes the smart pointer with a null pointer.
CopiedPtr()
- : mOwner(NULL)
- , mPointer(NULL)
+ : mOwner(nullptr)
+ , mPointer(nullptr)
{
}
/// @brief Construct from raw pointer
- /// @param pointer Initial pointer value, can be NULL. Must be convertible to T*.
+ /// @param pointer Initial pointer value, can be nullptr. Must be convertible to T*.
template <typename U>
explicit CopiedPtr(U* pointer)
: mOwner( detail::newPtrOwner<T>(pointer, OperatorNewCopy<U>(), OperatorDelete<U>()) )
@@ -74,7 +74,7 @@ class CopiedPtr
}
/// @brief Construct from raw pointer with cloner and deleter
- /// @param pointer Initial pointer value, can be NULL. Must be convertible to T*.
+ /// @param pointer Initial pointer value, can be nullptr. Must be convertible to T*.
/// @param cloner Callable with signature <b>T*(const T*)</b> that is invoked during CopiedPtr copies.
/// Must return a pointer to a copy of the argument.
/// @param deleter Callable with signature <b>void(T*)</b> that is invoked during CopiedPtr destruction.
@@ -87,17 +87,17 @@ class CopiedPtr
/// @brief Copy constructor
/// @param origin Original smart pointer
- /// @details If the origin's pointer is NULL, this pointer will also be NULL.
+ /// @details If the origin's pointer is nullptr, this pointer will also be nullptr.
/// Otherwise, this instance will hold the pointer returned by the cloner.
CopiedPtr(const CopiedPtr& origin)
- : mOwner(origin.mOwner ? origin.mOwner->clone() : NULL)
- , mPointer(origin.mOwner ? mOwner->getPointer() : NULL)
+ : mOwner(origin.mOwner ? origin.mOwner->clone() : nullptr)
+ , mPointer(origin.mOwner ? mOwner->getPointer() : nullptr)
{
}
/// @brief Construct from different CopiedPtr
/// @param origin Original smart pointer, where U* convertible to T*. Can refer to a derived object.
- /// @details If the origin's pointer is NULL, this pointer will also be NULL.
+ /// @details If the origin's pointer is nullptr, this pointer will also be nullptr.
/// Otherwise, this instance will hold the pointer returned by the cloner.
template <typename U>
CopiedPtr(const CopiedPtr<U>& origin)
@@ -106,7 +106,6 @@ class CopiedPtr
{
}
-#ifdef AURORA_HAS_CPP11
/// @brief Move constructor
/// @param source RValue reference to object of which the ownership is taken.
template <typename U>
@@ -114,10 +113,9 @@ class CopiedPtr
: mOwner(source.mOwner)
, mPointer(source.mPointer)
{
- source.mOwner = NULL;
- source.mPointer = NULL;
+ source.mOwner = nullptr;
+ source.mPointer = nullptr;
}
-#endif // AURORA_HAS_CPP11
/// @brief Copy assignment operator
/// @param origin Original smart pointer
@@ -138,7 +136,6 @@ class CopiedPtr
return *this;
}
-#ifdef AURORA_HAS_CPP11
/// @brief Move assignment operator
/// @param source RValue reference to object of which the ownership is taken.
template <typename U>
@@ -147,7 +144,6 @@ class CopiedPtr
CopiedPtr(std::move(source)).swap(*this);
return *this;
}
-#endif // AURORA_HAS_CPP11
/// @brief Destructor
/// @details Invokes the deleter with the stored pointer as argument.
@@ -167,7 +163,7 @@ class CopiedPtr
/// @brief Dereferences the pointer.
///
- AURORA_FAKE_DOC(typename std::tr1::add_reference<T>::type, T&) operator* () const
+ AURORA_FAKE_DOC(typename std::add_lvalue_reference<T>::type, T&) operator* () const
{
assert(mPointer);
return *mPointer;
@@ -181,12 +177,12 @@ class CopiedPtr
return mPointer;
}
- /// @brief Checks if the smart pointer is not NULL.
+ /// @brief Checks if the smart pointer is not nullptr.
/// @details Allows expressions of the form <i>if (ptr)</i> or <i>if (!ptr)</i>.
/// @return Value convertible to true, if CopiedPtr is not empty; value convertible to false otherwise
operator SafeBool() const
{
- return toSafeBool(mPointer != NULL);
+ return toSafeBool(mPointer != nullptr);
}
/// @brief Permits access to the internal pointer. Designed for rare use.
@@ -214,7 +210,7 @@ class CopiedPtr
}
/// @brief Reset to raw pointer
- /// @param pointer Initial pointer value, can be NULL. Must be convertible to T*.
+ /// @param pointer Initial pointer value, can be nullptr. Must be convertible to T*.
/// @details If this instance currently holds a pointer, the old deleter is invoked.
template <typename U>
void reset(U* pointer)
@@ -223,7 +219,7 @@ class CopiedPtr
}
/// @brief Reset to raw pointer with cloner and deleter
- /// @param pointer Initial pointer value, can be NULL. Must be convertible to T*.
+ /// @param pointer Initial pointer value, can be nullptr. Must be convertible to T*.
/// @param cloner Callable with signature <b>T*(const T*)</b> that is invoked during CopiedPtr copies.
/// Must return a pointer to a copy of the argument.
/// @param deleter Callable with signature <b>void(T*)</b> that is invoked during CopiedPtr destruction.
View
3  extlibs/aurora/include/Aurora/SmartPtr/Detail/PtrOwner.hpp
@@ -28,7 +28,6 @@
#include <Aurora/Tools/NonCopyable.hpp>
#include <cassert>
-#include <cstddef>
namespace aur
@@ -83,7 +82,7 @@ namespace detail
virtual void dismiss()
{
- pointer = NULL;
+ pointer = nullptr;
}
U* pointer;
View
151 extlibs/aurora/include/Aurora/Tools/Detail/Metaprogramming.hpp
@@ -1,151 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////
-//
-// Aurora C++ Library
-// Copyright (c) 2012 Jan Haller
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-// claim that you wrote the original software. If you use this software
-// in a product, an acknowledgment in the product documentation would be
-// appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not be
-// misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source distribution.
-//
-/////////////////////////////////////////////////////////////////////////////////
-
-#ifndef AURORA_METAPROGRAMMING_HPP
-#define AURORA_METAPROGRAMMING_HPP
-
-#include <Aurora/Config.hpp>
-
-#include AURORA_TR1_HEADER(type_traits)
-
-
-namespace aur
-{
-namespace detail
-{
-
- // Selects a type depending on a boolean condition.
- // If Condition is true, the result member Type evaluates to TrueType, otherwise to FalseType.
- template <bool Condition, typename TrueType, typename FalseType>
- struct Conditional
- {
- typedef TrueType Type;
- };
-
- template <typename TrueType, typename FalseType>
- struct Conditional<false, TrueType, FalseType>
- {
- typedef FalseType Type;
- };
-
-
- // Removes reference and pointer attribute from type
- template <typename T>
- struct RemoveIndirection
- {
- typedef typename std::tr1::remove_pointer<
- typename std::tr1::remove_reference<T>::type
- >::type Type;
- };
-
-
- // Removes reference, pointer and const attribute from type
- template <typename T>
- struct Decay
- {
- typedef typename std::tr1::remove_const<
- typename RemoveIndirection<T>::Type
- >::type Type;
- };
-
-
- // Type wrapper for overloaded functions
- template <typename T>
- struct Type2Type
- {
- };
-
- // Integer wrapper for overloaded functions
- template <int N>
- struct Int2Type
- {
- };
-
-
- // SFINAE Enable If
- template <bool Condition>
- struct EnableIf;
-
- template <>
- struct EnableIf<true>
- {
- typedef void Type;
- };
-
- #define AURORA_ENABLE_IF(...) typename ::aur::detail::EnableIf<__VA_ARGS__>::Type* = NULL
- #define AURORA_DISABLE_IF(...) AURORA_ENABLE_IF(!(__VA_ARGS__))
-
-
- // Adjusts New such that it has the same const, pointer, reference attributes as Origin
- template <typename Origin, typename New>
- struct Replicate
- {
- typedef typename Decay<New>::Type New0;
-
- typedef typename Conditional<
- std::tr1::is_const<typename RemoveIndirection<Origin>::Type>::value,
- const New0,
- New0>::Type New1;
-
- typedef typename Conditional<std::tr1::is_pointer<Origin>::value, New1*, New1>::Type New2;
- typedef typename Conditional<std::tr1::is_reference<Origin>::value, New2&, New2>::Type New3;
- typedef typename Conditional<std::tr1::is_const<Origin>::value, const New3, New3>::Type Type;
- };
-
- // Human-readable form
- #define AURORA_REPLICATE(Origin, New) typename aur::detail::Replicate<Origin, New>::Type
-
-
- // Static assertion
- // Generates a compiler error upon false condition.
- template <bool Condition>
- struct StaticAssert
- {
- };
-
- template <>
- struct StaticAssert<false>;
-
- template <int N>
- struct StaticChecker
- {
- };
-
- // Macro concatenation, evaluating arguments
- #define AURORA_DETAIL_PP_CONCAT_IMPL(a, b) a ## b
- #define AURORA_DETAIL_PP_CONCAT(a, b) AURORA_DETAIL_PP_CONCAT_IMPL(a, b)
-
-#ifdef AURORA_HAS_CPP11
- #define AURORA_STATIC_ASSERT(condition) static_assert(condition, "Static assertion failed.");
-#else
- // Static assert: Use line-dependent macro to avoid name collisions with multiple static asserts in the same scope
- #define AURORA_STATIC_ASSERT(condition) typedef aur::detail::StaticChecker< sizeof(aur::detail::StaticAssert<(condition)>) > \
- AURORA_DETAIL_PP_CONCAT(aurStaticChecker, __LINE__);
-#endif // AURORA_HAS_CPP11
-
-} // namespace detail
-} // namespace aur
-
-#endif // AURORA_METAPROGRAMMING_HPP
View
55 extlibs/aurora/include/Aurora/Tools/Distribution.hpp
@@ -29,63 +29,50 @@
#ifndef AURORA_DISTRIBUTION_HPP
#define AURORA_DISTRIBUTION_HPP
-#include <Aurora/Tools/Detail/Metaprogramming.hpp>
+#include <Aurora/Tools/Metaprogramming.hpp>
#include <Aurora/Config.hpp>
-#include AURORA_TR1_HEADER(functional)
+#include <functional>
namespace aur
{
- namespace detail
- {
-
- template <typename T>
- struct Constant
- {
- explicit Constant(T value)
- : value(value)
- {
- }
-
- T operator() () const
- {
- return value;
- }
-
- T value;
- };
-
- } // namespace detail
-
/// @addtogroup Tools
/// @{
/// @brief Class holding a rule to create values with predefined properties
/// @details Contains a callback that returns values on demand. These can be constant (always the same value), according to a
-/// random distribution, or be read from a value elsewhere in your code.
+/// random distribution, or be read from a value elsewhere in your code. Generally, the callback can be any function, member
+/// function or functor returning a value of type T and taking no arguments.
template <typename T>
class Distribution
{
// ---------------------------------------------------------------------------------------------------------------------------
// Private types
private:
- typedef std::tr1::function<T()> FactoryFn;
+ typedef std::function<T()> FactoryFn;
// ---------------------------------------------------------------------------------------------------------------------------
// Public member functions
public:
- /// @brief Implicit constructor from a constant value
- /// @details
+ /// @brief Construct from constant
+ /// @param constant Constant value convertible to T.
template <typename U>
- Distribution(U initializer)
- : mFactory(typename detail::Conditional<
- std::tr1::is_convertible<U, T>::value,
- detail::Constant<T>,
- FactoryFn
- >::Type(initializer))
+ Distribution(U constant AURORA_ENABLE_IF(std::is_convertible<U, T>::value))
+ : mFactory()
+ {
+ // Convert to T first to avoid conversion happening at every function call.
+ T copy = constant;
+ mFactory = [copy] () { return copy; };
+ }
+
+ /// @brief Construct from distribution function
+ /// @param function Callable convertible to std::function<T()> in order to act as distribution function.
+ template <typename Fn>
+ Distribution(Fn function AURORA_ENABLE_IF(!std::is_convertible<Fn, T>::value))
+ : mFactory(function)
{
}
@@ -110,7 +97,7 @@ class Distribution
FactoryFn mFactory;
};
-/// @relates
+/// @relates Distribution
/// @brief Swaps two Distribution<T> instances.
template <typename T>
void swap(Distribution<T>& lhs, Distribution<T>& rhs)
View
114 extlibs/aurora/include/Aurora/Tools/Metaprogramming.hpp
@@ -0,0 +1,114 @@
+/////////////////////////////////////////////////////////////////////////////////
+//
+// Aurora C++ Library
+// Copyright (c) 2012 Jan Haller
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+/////////////////////////////////////////////////////////////////////////////////
+
+#ifndef AURORA_METAPROGRAMMING_HPP
+#define AURORA_METAPROGRAMMING_HPP
+
+#include <Aurora/Config.hpp>
+
+#include <type_traits>
+
+
+namespace aur
+{
+
+/// @addtogroup Tools
+/// @{
+
+/// @brief Simple type wrapper, can be used for overload resolution.
+///
+template <typename T>
+struct Type
+{
+};
+
+/// @brief Simple integer wrapper, can be used for overload resolution.
+///
+template <int N>
+struct Int
+{
+};
+
+
+/// @brief SFINAE Enable If Macro for parameter lists
+/// @details Usage:
+/// @code
+/// template <typename T>
+/// void Function(T value
+/// AURORA_ENABLE_IF(std::is_integral<T>::value));
+/// @endcode
+#define AURORA_ENABLE_IF(...) , typename std::enable_if<__VA_ARGS__>::type* = nullptr
+
+/// @}
+
+// ---------------------------------------------------------------------------------------------------------------------------
+
+
+namespace detail
+{
+
+ // Removes reference and pointer attribute from type
+ template <typename T>
+ struct RemoveIndirection
+ {
+ typedef typename std::remove_pointer<
+ typename std::remove_reference<T>::type
+ >::type type;
+ };
+
+
+ // Removes reference, pointer and const attribute from type
+ template <typename T>
+ struct RawType
+ {
+ typedef typename std::remove_const<
+ typename RemoveIndirection<T>::type
+ >::type type;
+ };
+
+
+ // Adjusts New such that it has the same const, pointer, reference attributes as Origin
+ template <typename Origin, typename New>
+ struct Replicate
+ {
+ typedef typename RawType<New>::type raw;
+
+ typedef typename std::conditional<
+ std::is_const<typename RemoveIndirection<Origin>::type>::value,
+ const raw,
+ raw>::type c_qualified;
+
+ typedef typename std::conditional<std::is_pointer<Origin>::value, c_qualified*, c_qualified>::type cp_qualified;
+ typedef typename std::conditional<std::is_reference<Origin>::value, cp_qualified&, cp_qualified>::type cpr_qualified;
+ typedef typename std::conditional<std::is_const<Origin>::value, const cpr_qualified, cpr_qualified>::type type;
+ };
+
+ // Human-readable form
+ #define AURORA_REPLICATE(Origin, New) typename aur::detail::Replicate<Origin, New>::type
+
+} // namespace detail
+} // namespace aur
+
+#endif // AURORA_METAPROGRAMMING_HPP
View
4 extlibs/aurora/include/Aurora/Tools/SafeBool.hpp
@@ -29,8 +29,6 @@
#ifndef AURORA_SAFEBOOL_HPP
#define AURORA_SAFEBOOL_HPP
-#include <cstddef> // NULL
-
namespace aur
{
@@ -63,7 +61,7 @@ const SafeBool SafeBoolTrue = &detail::SafeBoolHolder::Function;
/// @brief SafeBool literal, evaluates to false
/// @hideinitializer
-const SafeBool SafeBoolFalse = NULL;
+const SafeBool SafeBoolFalse = nullptr;
/// @brief Conversion function from bool to SafeBool
///
View
4 extlibs/aurora/include/Aurora/Tools/TypeInfo.hpp
@@ -32,7 +32,7 @@
#include <Aurora/Config.hpp>
#include <typeinfo>
-#include AURORA_TR1_HEADER(type_traits)
+#include <type_traits>
namespace aur
@@ -102,7 +102,7 @@ namespace detail
template <typename T>
TypeInfo derefTypeid()
{
- return typeid(typename std::tr1::remove_pointer<T>::type);
+ return typeid(typename std::remove_pointer<T>::type);
}
} // namespace detail
Please sign in to comment.
Something went wrong with that request. Please try again.