added ENTT_NOEXCEPT macro to fully disable exception handling (ie required with UE4)

This commit is contained in:
Michele Caini
2018-04-18 16:36:14 +02:00
parent c54cedf14b
commit 8c73cac72f
18 changed files with 222 additions and 197 deletions

1
TODO
View File

@@ -2,7 +2,6 @@
* scene management (I prefer the concept of spaces, that is a kind of scene anyway)
* review doc: separate it in multiple md/dox files, reduce the readme to a minimum and provide users with links to the online documentation on gh-pages
* debugging tools (#60): the issue online already contains interesting tips on this, look at it
* define a macro for the noexcept policy, so as to provide users with an easy way to disable exception handling
* define basic reactive systems (track entities to which component is attached, track entities from which component is removed, and so on)
* define systems as composable mixins (initializazion, reactive, update, whatever) with flexible auto-detected arguments (registry, views, etc)
* does it worth it to add an optional functor to the member functions of snapshot so as to filter out instances and entities?

10
src/entt/config/config.h Normal file
View File

@@ -0,0 +1,10 @@
#ifndef ENTT_CONFIG_CONFIG_H
#define ENTT_CONFIG_CONFIG_H
#ifndef ENTT_NOEXCEPT
#define ENTT_NOEXCEPT noexcept
#endif
#endif // ENTT_CONFIG_CONFIG_H

View File

@@ -5,6 +5,7 @@
#include<type_traits>
#include<cstddef>
#include<atomic>
#include "../config/config.h"
namespace entt {
@@ -22,7 +23,7 @@ class Family {
static std::atomic<std::size_t> identifier;
template<typename...>
static std::size_t family() noexcept {
static std::size_t family() ENTT_NOEXCEPT {
static const std::size_t value = identifier.fetch_add(1);
return value;
}
@@ -36,7 +37,7 @@ public:
* @return Statically generated unique identifier for the given type.
*/
template<typename... Type>
inline static family_type type() noexcept {
inline static family_type type() ENTT_NOEXCEPT {
return family<std::decay_t<Type>...>();
}
};

View File

@@ -4,6 +4,7 @@
#include <cstddef>
#include <cstdint>
#include "../config/config.h"
namespace entt {
@@ -21,7 +22,7 @@ namespace entt {
class HashedString final {
struct ConstCharWrapper final {
// non-explicit constructor on purpose
constexpr ConstCharWrapper(const char *str) noexcept: str{str} {}
constexpr ConstCharWrapper(const char *str) ENTT_NOEXCEPT: str{str} {}
const char *str;
};
@@ -29,7 +30,7 @@ class HashedString final {
static constexpr std::uint64_t prime = 1099511628211ull;
// FowlerNollVo hash function v. 1a - the good
static constexpr std::uint64_t helper(std::uint64_t partial, const char *str) noexcept {
static constexpr std::uint64_t helper(std::uint64_t partial, const char *str) ENTT_NOEXCEPT {
return str[0] == 0 ? partial : helper((partial^str[0])*prime, str+1);
}
@@ -52,7 +53,7 @@ public:
* @param str Human-readable identifer.
*/
template <std::size_t N>
constexpr HashedString(const char (&str)[N]) noexcept
constexpr HashedString(const char (&str)[N]) ENTT_NOEXCEPT
: hash{helper(offset, str)}, str{str}
{}
@@ -62,7 +63,7 @@ public:
*
* @param wrapper Helps achieving the purpose by relying on overloading.
*/
explicit constexpr HashedString(ConstCharWrapper wrapper) noexcept
explicit constexpr HashedString(ConstCharWrapper wrapper) ENTT_NOEXCEPT
: hash{helper(offset, wrapper.str)}, str{wrapper.str}
{}
@@ -70,20 +71,20 @@ public:
* @brief Returns the human-readable representation of a hashed string.
* @return The string used to initialize the instance.
*/
constexpr operator const char *() const noexcept { return str; }
constexpr operator const char *() const ENTT_NOEXCEPT { return str; }
/**
* @brief Returns the numeric representation of a hashed string.
* @return The numeric representation of the instance.
*/
constexpr operator hash_type() const noexcept { return hash; }
constexpr operator hash_type() const ENTT_NOEXCEPT { return hash; }
/**
* @brief Compares two hashed strings.
* @param other Hashed string with which to compare.
* @return True if the two hashed strings are identical, false otherwise.
*/
constexpr bool operator==(const HashedString &other) const noexcept {
constexpr bool operator==(const HashedString &other) const ENTT_NOEXCEPT {
return hash == other.hash;
}
@@ -99,7 +100,7 @@ private:
* @param rhs A valid hashed string.
* @return True if the two hashed strings are identical, false otherwise.
*/
constexpr bool operator!=(const HashedString &lhs, const HashedString &rhs) noexcept {
constexpr bool operator!=(const HashedString &lhs, const HashedString &rhs) ENTT_NOEXCEPT {
return !(lhs == rhs);
}

View File

@@ -4,6 +4,7 @@
#include <cassert>
#include <utility>
#include "../config/config.h"
#include "registry.hpp"
#include "utility.hpp"
@@ -111,7 +112,7 @@ struct Actor {
* @return True if the actor owns the tag, false otherwise.
*/
template<typename Tag>
bool has(tag_type_t) const noexcept {
bool has(tag_type_t) const ENTT_NOEXCEPT {
return (reg.template has<Tag>() && (reg.template attachee<Tag>() == entt));
}
@@ -121,7 +122,7 @@ struct Actor {
* @return True if the actor has the component, false otherwise.
*/
template<typename Component>
bool has() const noexcept {
bool has() const ENTT_NOEXCEPT {
return reg.template has<Component>(entt);
}
@@ -131,7 +132,7 @@ struct Actor {
* @return A reference to the instance of the tag owned by the actor.
*/
template<typename Tag>
const Tag & get(tag_type_t) const noexcept {
const Tag & get(tag_type_t) const ENTT_NOEXCEPT {
assert(has<Tag>(tag_type_t{}));
return reg.template get<Tag>();
}
@@ -142,7 +143,7 @@ struct Actor {
* @return A reference to the instance of the tag owned by the actor.
*/
template<typename Tag>
Tag & get(tag_type_t) noexcept {
Tag & get(tag_type_t) ENTT_NOEXCEPT {
return const_cast<Tag &>(const_cast<const Actor *>(this)->get<Tag>(tag_type_t{}));
}
@@ -152,7 +153,7 @@ struct Actor {
* @return A reference to the instance of the component owned by the actor.
*/
template<typename Component>
const Component & get() const noexcept {
const Component & get() const ENTT_NOEXCEPT {
return reg.template get<Component>(entt);
}
@@ -162,7 +163,7 @@ struct Actor {
* @return A reference to the instance of the component owned by the actor.
*/
template<typename Component>
Component & get() noexcept {
Component & get() ENTT_NOEXCEPT {
return const_cast<Component &>(const_cast<const Actor *>(this)->get<Component>());
}
@@ -170,7 +171,7 @@ struct Actor {
* @brief Returns a reference to the underlying registry.
* @return A reference to the underlying registry.
*/
const registry_type & registry() const noexcept {
const registry_type & registry() const ENTT_NOEXCEPT {
return reg;
}
@@ -178,7 +179,7 @@ struct Actor {
* @brief Returns a reference to the underlying registry.
* @return A reference to the underlying registry.
*/
registry_type & registry() noexcept {
registry_type & registry() ENTT_NOEXCEPT {
return const_cast<registry_type &>(const_cast<const Actor *>(this)->registry());
}
@@ -186,7 +187,7 @@ struct Actor {
* @brief Returns the entity associated with an actor.
* @return The entity associated with the actor.
*/
entity_type entity() const noexcept {
entity_type entity() const ENTT_NOEXCEPT {
return entt;
}

View File

@@ -11,6 +11,7 @@
#include <cassert>
#include <algorithm>
#include <type_traits>
#include "../config/config.h"
#include "../core/family.hpp"
#include "../signal/sigh.hpp"
#include "entt_traits.hpp"
@@ -71,14 +72,14 @@ class Registry {
};
template<typename Component>
const SparseSet<Entity, Component> & pool() const noexcept {
const SparseSet<Entity, Component> & pool() const ENTT_NOEXCEPT {
const auto ctype = component_family::type<Component>();
assert(ctype < pools.size() && std::get<0>(pools[ctype]));
return static_cast<SparseSet<Entity, Component> &>(*std::get<0>(pools[ctype]));
}
template<typename Component>
SparseSet<Entity, Component> & pool() noexcept {
SparseSet<Entity, Component> & pool() ENTT_NOEXCEPT {
return const_cast<SparseSet<Entity, Component> &>(const_cast<const Registry *>(this)->pool<Component>());
}
@@ -146,7 +147,7 @@ public:
* @return Runtime numeric identifier of the given type of tag.
*/
template<typename Tag>
tag_type type(tag_type_t) const noexcept {
tag_type type(tag_type_t) const ENTT_NOEXCEPT {
return tag_family::type<Tag>();
}
@@ -163,7 +164,7 @@ public:
* @return Runtime numeric identifier of the given type of component.
*/
template<typename Component>
component_type type() const noexcept {
component_type type() const ENTT_NOEXCEPT {
return component_family::type<Component>();
}
@@ -173,7 +174,7 @@ public:
* @return Number of existing components of the given type.
*/
template<typename Component>
size_type size() const noexcept {
size_type size() const ENTT_NOEXCEPT {
const auto ctype = component_family::type<Component>();
return ((ctype < pools.size()) && std::get<0>(pools[ctype])) ? std::get<0>(pools[ctype])->size() : size_type{};
}
@@ -182,7 +183,7 @@ public:
* @brief Returns the number of entities still in use.
* @return Number of entities still in use.
*/
size_type size() const noexcept {
size_type size() const ENTT_NOEXCEPT {
return entities.size() - available;
}
@@ -217,7 +218,7 @@ public:
* @brief Returns the number of entities ever created.
* @return Number of entities ever created.
*/
size_type capacity() const noexcept {
size_type capacity() const ENTT_NOEXCEPT {
return entities.size();
}
@@ -228,7 +229,7 @@ public:
* otherwise.
*/
template<typename Component>
bool empty() const noexcept {
bool empty() const ENTT_NOEXCEPT {
const auto ctype = component_family::type<Component>();
return (!(ctype < pools.size()) || !std::get<0>(pools[ctype]) || std::get<0>(pools[ctype])->empty());
}
@@ -237,7 +238,7 @@ public:
* @brief Checks if there exists at least an entity still in use.
* @return True if at least an entity is still in use, false otherwise.
*/
bool empty() const noexcept {
bool empty() const ENTT_NOEXCEPT {
return entities.size() == available;
}
@@ -246,7 +247,7 @@ public:
* @param entity An entity identifier, either valid or not.
* @return True if the identifier is valid, false otherwise.
*/
bool valid(entity_type entity) const noexcept {
bool valid(entity_type entity) const ENTT_NOEXCEPT {
const auto pos = size_type(entity & traits_type::entity_mask);
return (pos < entities.size() && entities[pos] == entity);
}
@@ -268,7 +269,7 @@ public:
* @param entity A valid entity identifier.
* @return True if the identifier is valid, false otherwise.
*/
bool fast(entity_type entity) const noexcept {
bool fast(entity_type entity) const ENTT_NOEXCEPT {
const auto pos = size_type(entity & traits_type::entity_mask);
assert(pos < entities.size());
return (entities[pos] == entity);
@@ -279,7 +280,7 @@ public:
* @param entity An entity identifier, either valid or not.
* @return Version stored along with the given entity identifier.
*/
version_type version(entity_type entity) const noexcept {
version_type version(entity_type entity) const ENTT_NOEXCEPT {
return version_type((entity >> traits_type::entity_shift) & traits_type::version_mask);
}
@@ -300,7 +301,7 @@ public:
* @param entity A valid entity identifier.
* @return Actual version for the given entity identifier.
*/
version_type current(entity_type entity) const noexcept {
version_type current(entity_type entity) const ENTT_NOEXCEPT {
const auto pos = size_type(entity & traits_type::entity_mask);
assert(pos < entities.size());
return version_type((entities[pos] >> traits_type::entity_shift) & traits_type::version_mask);
@@ -323,7 +324,7 @@ public:
*
* @return A valid entity identifier.
*/
entity_type create() noexcept {
entity_type create() ENTT_NOEXCEPT {
entity_type entity;
if(available) {
@@ -491,7 +492,7 @@ public:
* @return True if the tag already has an owner, false otherwise.
*/
template<typename Tag>
bool has() const noexcept {
bool has() const ENTT_NOEXCEPT {
const auto ttype = tag_family::type<Tag>();
bool found = false;
@@ -517,7 +518,7 @@ public:
* @return True if the entity has all the components, false otherwise.
*/
template<typename... Component>
bool has(entity_type entity) const noexcept {
bool has(entity_type entity) const ENTT_NOEXCEPT {
assert(valid(entity));
using accumulator_type = bool[];
bool all = true;
@@ -540,7 +541,7 @@ public:
* @return A reference to the tag.
*/
template<typename Tag>
const Tag & get() const noexcept {
const Tag & get() const ENTT_NOEXCEPT {
assert(has<Tag>());
return static_cast<Attaching<Tag> *>(std::get<0>(tags[tag_family::type<Tag>()]).get())->tag;
}
@@ -558,7 +559,7 @@ public:
* @return A reference to the tag.
*/
template<typename Tag>
Tag & get() noexcept {
Tag & get() ENTT_NOEXCEPT {
return const_cast<Tag &>(const_cast<const Registry *>(this)->get<Tag>());
}
@@ -577,7 +578,7 @@ public:
* @return A reference to the component owned by the entity.
*/
template<typename Component>
const Component & get(entity_type entity) const noexcept {
const Component & get(entity_type entity) const ENTT_NOEXCEPT {
assert(valid(entity));
const auto ctype = component_family::type<Component>();
assert((ctype < pools.size()) && std::get<0>(pools[ctype]));
@@ -599,7 +600,7 @@ public:
* @return A reference to the component owned by the entity.
*/
template<typename Component>
Component & get(entity_type entity) noexcept {
Component & get(entity_type entity) ENTT_NOEXCEPT {
return const_cast<Component &>(const_cast<const Registry *>(this)->get<Component>(entity));
}
@@ -619,7 +620,7 @@ public:
*/
template<typename... Component>
std::enable_if_t<(sizeof...(Component) > 1), std::tuple<const Component &...>>
get(entity_type entity) const noexcept {
get(entity_type entity) const ENTT_NOEXCEPT {
return std::tuple<const Component &...>{get<Component>(entity)...};
}
@@ -639,7 +640,7 @@ public:
*/
template<typename... Component>
std::enable_if_t<(sizeof...(Component) > 1), std::tuple<Component &...>>
get(entity_type entity) noexcept {
get(entity_type entity) ENTT_NOEXCEPT {
return std::tuple<Component &...>{get<Component>(entity)...};
}
@@ -730,7 +731,7 @@ public:
* @return A valid entity identifier.
*/
template<typename Tag>
entity_type attachee() const noexcept {
entity_type attachee() const ENTT_NOEXCEPT {
assert(has<Tag>());
return std::get<0>(tags[tag_family::type<Tag>()])->entity;
}
@@ -790,7 +791,7 @@ public:
* @return A temporary sink object.
*/
template<typename Tag>
sink_type construction(tag_type_t) noexcept {
sink_type construction(tag_type_t) ENTT_NOEXCEPT {
assure<Tag>(tag_type_t{});
return std::get<1>(tags[tag_family::type<Tag>()]).sink();
}
@@ -819,7 +820,7 @@ public:
* @return A temporary sink object.
*/
template<typename Component>
sink_type construction() noexcept {
sink_type construction() ENTT_NOEXCEPT {
assure<Component>();
return std::get<1>(pools[component_family::type<Component>()]).sink();
}
@@ -848,7 +849,7 @@ public:
* @return A temporary sink object.
*/
template<typename Tag>
sink_type destruction(tag_type_t) noexcept {
sink_type destruction(tag_type_t) ENTT_NOEXCEPT {
assure<Tag>(tag_type_t{});
return std::get<2>(tags[tag_family::type<Tag>()]).sink();
}
@@ -877,7 +878,7 @@ public:
* @return A temporary sink object.
*/
template<typename Component>
sink_type destruction() noexcept {
sink_type destruction() ENTT_NOEXCEPT {
assure<Component>();
return std::get<2>(pools[component_family::type<Component>()]).sink();
}
@@ -1223,7 +1224,7 @@ public:
* @return True if the view has already been prepared, false otherwise.
*/
template<typename... Component>
bool contains() const noexcept {
bool contains() const ENTT_NOEXCEPT {
static_assert(sizeof...(Component) > 1, "!");
const auto htype = handler_family::type<Component...>();
return (htype < handlers.size() && handlers[htype]);

View File

@@ -9,6 +9,7 @@
#include <cassert>
#include <iterator>
#include <type_traits>
#include "../config/config.h"
#include "entt_traits.hpp"
#include "utility.hpp"
@@ -41,7 +42,7 @@ class Snapshot final {
using follow_fn_type = Entity(*)(const Registry<Entity> &, Entity);
using raw_fn_type = const Entity *(*)(const Registry<Entity> &, typename Registry<Entity>::component_type);
Snapshot(const Registry<Entity> &registry, Entity seed, std::size_t size, follow_fn_type follow, raw_fn_type raw) noexcept
Snapshot(const Registry<Entity> &registry, Entity seed, std::size_t size, follow_fn_type follow, raw_fn_type raw) ENTT_NOEXCEPT
: registry{registry},
seed{seed},
size{size},
@@ -196,7 +197,7 @@ class SnapshotLoader final {
using assure_fn_type = void(*)(Registry<Entity> &, Entity, bool);
SnapshotLoader(Registry<Entity> &registry, assure_fn_type assure_fn) noexcept
SnapshotLoader(Registry<Entity> &registry, assure_fn_type assure_fn) ENTT_NOEXCEPT
: registry{registry},
assure_fn{assure_fn}
{
@@ -490,7 +491,7 @@ public:
* @brief Constructs a loader that is bound to a given registry.
* @param registry A valid reference to a registry.
*/
ContinuousLoader(Registry<entity_type> &registry) noexcept
ContinuousLoader(Registry<entity_type> &registry) ENTT_NOEXCEPT
: registry{registry}
{}

View File

@@ -10,6 +10,7 @@
#include <cstddef>
#include <cassert>
#include <type_traits>
#include "../config/config.h"
#include "entt_traits.hpp"
@@ -68,33 +69,33 @@ class SparseSet<Entity> {
: direct{direct}, pos{pos}
{}
Iterator & operator++() noexcept {
Iterator & operator++() ENTT_NOEXCEPT {
return --pos, *this;
}
Iterator operator++(int) noexcept {
Iterator operator++(int) ENTT_NOEXCEPT {
Iterator orig = *this;
return ++(*this), orig;
}
Iterator & operator+=(difference_type value) noexcept {
Iterator & operator+=(difference_type value) ENTT_NOEXCEPT {
pos -= value;
return *this;
}
Iterator operator+(difference_type value) noexcept {
Iterator operator+(difference_type value) ENTT_NOEXCEPT {
return Iterator{direct, pos-value};
}
bool operator==(const Iterator &other) const noexcept {
bool operator==(const Iterator &other) const ENTT_NOEXCEPT {
return other.pos == pos;
}
bool operator!=(const Iterator &other) const noexcept {
bool operator!=(const Iterator &other) const ENTT_NOEXCEPT {
return !(*this == other);
}
reference operator*() const noexcept {
reference operator*() const ENTT_NOEXCEPT {
return direct[pos-1];
}
@@ -116,10 +117,10 @@ public:
using iterator_type = Iterator;
/*! @brief Default constructor. */
SparseSet() noexcept = default;
SparseSet() ENTT_NOEXCEPT = default;
/*! @brief Default destructor. */
virtual ~SparseSet() noexcept = default;
virtual ~SparseSet() ENTT_NOEXCEPT = default;
/*! @brief Copying a sparse set isn't allowed. */
SparseSet(const SparseSet &) = delete;
@@ -153,7 +154,7 @@ public:
*
* @return Extent of the sparse set.
*/
size_type extent() const noexcept {
size_type extent() const ENTT_NOEXCEPT {
return reverse.size();
}
@@ -167,7 +168,7 @@ public:
*
* @return Number of elements.
*/
size_type size() const noexcept {
size_type size() const ENTT_NOEXCEPT {
return direct.size();
}
@@ -175,7 +176,7 @@ public:
* @brief Checks whether a sparse set is empty.
* @return True if the sparse set is empty, false otherwise.
*/
bool empty() const noexcept {
bool empty() const ENTT_NOEXCEPT {
return direct.empty();
}
@@ -194,7 +195,7 @@ public:
*
* @return A pointer to the internal packed array.
*/
const entity_type * data() const noexcept {
const entity_type * data() const ENTT_NOEXCEPT {
return direct.data();
}
@@ -210,7 +211,7 @@ public:
*
* @return An iterator to the first entity of the internal packed array.
*/
iterator_type begin() const noexcept {
iterator_type begin() const ENTT_NOEXCEPT {
return Iterator{direct, direct.size()};
}
@@ -227,7 +228,7 @@ public:
* @return An iterator to the element following the last entity of the
* internal packed array.
*/
iterator_type end() const noexcept {
iterator_type end() const ENTT_NOEXCEPT {
return Iterator{direct, 0};
}
@@ -236,7 +237,7 @@ public:
* @param entity A valid entity identifier.
* @return True if the sparse set contains the entity, false otherwise.
*/
bool has(entity_type entity) const noexcept {
bool has(entity_type entity) const ENTT_NOEXCEPT {
const auto pos = size_type(entity & traits_type::entity_mask);
// the in-use control bit permits to avoid accessing the direct vector
return (pos < reverse.size()) && (reverse[pos] != pending);
@@ -259,7 +260,7 @@ public:
* @param entity A valid entity identifier.
* @return True if the sparse set contains the entity, false otherwise.
*/
bool fast(entity_type entity) const noexcept {
bool fast(entity_type entity) const ENTT_NOEXCEPT {
const auto pos = size_type(entity & traits_type::entity_mask);
assert(pos < reverse.size());
// the in-use control bit permits to avoid accessing the direct vector
@@ -278,7 +279,7 @@ public:
* @param entity A valid entity identifier.
* @return The position of the entity in the sparse set.
*/
pos_type get(entity_type entity) const noexcept {
pos_type get(entity_type entity) const ENTT_NOEXCEPT {
assert(has(entity));
return reverse[entity & traits_type::entity_mask];
}
@@ -344,7 +345,7 @@ public:
* @param lhs A valid position within the sparse set.
* @param rhs A valid position within the sparse set.
*/
void swap(pos_type lhs, pos_type rhs) noexcept {
void swap(pos_type lhs, pos_type rhs) ENTT_NOEXCEPT {
assert(lhs < direct.size());
assert(rhs < direct.size());
auto &src = direct[lhs];
@@ -372,7 +373,7 @@ public:
*
* @param other The sparse sets that imposes the order of the entities.
*/
void respect(const SparseSet<Entity> &other) noexcept {
void respect(const SparseSet<Entity> &other) ENTT_NOEXCEPT {
auto from = other.begin();
auto to = other.end();
@@ -442,37 +443,37 @@ class SparseSet<Entity, Type>: public SparseSet<Entity> {
: instances{instances}, pos{pos}
{}
Iterator & operator++() noexcept {
Iterator & operator++() ENTT_NOEXCEPT {
return --pos, *this;
}
Iterator operator++(int) noexcept {
Iterator operator++(int) ENTT_NOEXCEPT {
Iterator orig = *this;
return ++(*this), orig;
}
Iterator & operator+=(difference_type value) noexcept {
Iterator & operator+=(difference_type value) ENTT_NOEXCEPT {
pos -= value;
return *this;
}
Iterator operator+(difference_type value) noexcept {
Iterator operator+(difference_type value) ENTT_NOEXCEPT {
return Iterator{instances, pos-value};
}
bool operator==(const Iterator &other) const noexcept {
bool operator==(const Iterator &other) const ENTT_NOEXCEPT {
return other.pos == pos;
}
bool operator!=(const Iterator &other) const noexcept {
bool operator!=(const Iterator &other) const ENTT_NOEXCEPT {
return !(*this == other);
}
reference operator*() noexcept {
reference operator*() ENTT_NOEXCEPT {
return instances[pos-1];
}
pointer operator->() noexcept {
pointer operator->() ENTT_NOEXCEPT {
return &instances.data()[pos-1];
}
@@ -494,7 +495,7 @@ public:
using iterator_type = Iterator;
/*! @brief Default constructor. */
SparseSet() noexcept = default;
SparseSet() ENTT_NOEXCEPT = default;
/*! @brief Copying a sparse set isn't allowed. */
SparseSet(const SparseSet &) = delete;
@@ -534,7 +535,7 @@ public:
*
* @return A pointer to the array of objects.
*/
const object_type * raw() const noexcept {
const object_type * raw() const ENTT_NOEXCEPT {
return instances.data();
}
@@ -553,7 +554,7 @@ public:
*
* @return A pointer to the array of objects.
*/
object_type * raw() noexcept {
object_type * raw() ENTT_NOEXCEPT {
return instances.data();
}
@@ -569,7 +570,7 @@ public:
*
* @return An iterator to the first instance of the given type.
*/
iterator_type begin() noexcept {
iterator_type begin() ENTT_NOEXCEPT {
return Iterator{instances, instances.size()};
}
@@ -587,7 +588,7 @@ public:
* @return An iterator to the element following the last instance of the
* given type.
*/
iterator_type end() noexcept {
iterator_type end() ENTT_NOEXCEPT {
return Iterator{instances, 0};
}
@@ -603,7 +604,7 @@ public:
* @param entity A valid entity identifier.
* @return The object associated to the entity.
*/
const object_type & get(entity_type entity) const noexcept {
const object_type & get(entity_type entity) const ENTT_NOEXCEPT {
return instances[underlying_type::get(entity)];
}
@@ -619,7 +620,7 @@ public:
* @param entity A valid entity identifier.
* @return The object associated to the entity.
*/
object_type & get(entity_type entity) noexcept {
object_type & get(entity_type entity) ENTT_NOEXCEPT {
return const_cast<object_type &>(const_cast<const SparseSet *>(this)->get(entity));
}
@@ -770,7 +771,7 @@ public:
*
* @param other The sparse sets that imposes the order of the entities.
*/
void respect(const SparseSet<Entity> &other) noexcept {
void respect(const SparseSet<Entity> &other) ENTT_NOEXCEPT {
auto from = other.begin();
auto to = other.end();

View File

@@ -8,6 +8,7 @@
#include <utility>
#include <algorithm>
#include <type_traits>
#include "../config/config.h"
#include "entt_traits.hpp"
#include "sparse_set.hpp"
@@ -76,7 +77,7 @@ class PersistentView final {
using view_type = SparseSet<Entity>;
using pattern_type = std::tuple<pool_type<Component> &...>;
PersistentView(view_type &view, pool_type<Component> &... pools) noexcept
PersistentView(view_type &view, pool_type<Component> &... pools) ENTT_NOEXCEPT
: view{view}, pools{pools...}
{}
@@ -92,7 +93,7 @@ public:
* @brief Returns the number of entities that have the given components.
* @return Number of entities that have the given components.
*/
size_type size() const noexcept {
size_type size() const ENTT_NOEXCEPT {
return view.size();
}
@@ -108,7 +109,7 @@ public:
*
* @return A pointer to the array of entities.
*/
const entity_type * data() const noexcept {
const entity_type * data() const ENTT_NOEXCEPT {
return view.data();
}
@@ -126,7 +127,7 @@ public:
*
* @return An iterator to the first entity that has the given components.
*/
iterator_type begin() const noexcept {
iterator_type begin() const ENTT_NOEXCEPT {
return view.begin();
}
@@ -145,7 +146,7 @@ public:
* @return An iterator to the entity following the last entity that has the
* given components.
*/
iterator_type end() const noexcept {
iterator_type end() const ENTT_NOEXCEPT {
return view.end();
}
@@ -154,7 +155,7 @@ public:
* @param entity A valid entity identifier.
* @return True if the view contains the given entity, false otherwise.
*/
bool contains(entity_type entity) const noexcept {
bool contains(entity_type entity) const ENTT_NOEXCEPT {
return view.has(entity) && (view.data()[view.get(entity)] == entity);
}
@@ -176,7 +177,7 @@ public:
* @return The component assigned to the entity.
*/
template<typename Comp>
const Comp & get(entity_type entity) const noexcept {
const Comp & get(entity_type entity) const ENTT_NOEXCEPT {
assert(contains(entity));
return std::get<pool_type<Comp> &>(pools).get(entity);
}
@@ -199,7 +200,7 @@ public:
* @return The component assigned to the entity.
*/
template<typename Comp>
Comp & get(entity_type entity) noexcept {
Comp & get(entity_type entity) ENTT_NOEXCEPT {
return const_cast<Comp &>(const_cast<const PersistentView *>(this)->get<Comp>(entity));
}
@@ -222,7 +223,7 @@ public:
*/
template<typename... Comp>
std::enable_if_t<(sizeof...(Comp) > 1), std::tuple<const Comp &...>>
get(entity_type entity) const noexcept {
get(entity_type entity) const ENTT_NOEXCEPT {
assert(contains(entity));
return std::tuple<const Comp &...>{get<Comp>(entity)...};
}
@@ -246,7 +247,7 @@ public:
*/
template<typename... Comp>
std::enable_if_t<(sizeof...(Comp) > 1), std::tuple<Comp &...>>
get(entity_type entity) noexcept {
get(entity_type entity) ENTT_NOEXCEPT {
assert(contains(entity));
return std::tuple<Comp &...>{get<Comp>(entity)...};
}
@@ -383,7 +384,7 @@ class View final {
class Iterator {
using size_type = typename view_type::size_type;
inline bool valid() const noexcept {
inline bool valid() const ENTT_NOEXCEPT {
const auto entity = *begin;
const auto sz = size_type(entity & traits_type::entity_mask);
auto pos = unchecked.size();
@@ -402,7 +403,7 @@ class View final {
using reference = typename underlying_iterator_type::reference;
using iterator_category = typename underlying_iterator_type::iterator_category;
Iterator(unchecked_type unchecked, size_type extent, underlying_iterator_type begin, underlying_iterator_type end) noexcept
Iterator(unchecked_type unchecked, size_type extent, underlying_iterator_type begin, underlying_iterator_type end) ENTT_NOEXCEPT
: unchecked{unchecked},
extent{extent},
begin{begin},
@@ -413,32 +414,32 @@ class View final {
}
}
Iterator & operator++() noexcept {
Iterator & operator++() ENTT_NOEXCEPT {
return (++begin != end && !valid()) ? ++(*this) : *this;
}
Iterator operator++(int) noexcept {
Iterator operator++(int) ENTT_NOEXCEPT {
Iterator orig = *this;
return ++(*this), orig;
}
Iterator & operator+=(difference_type value) noexcept {
Iterator & operator+=(difference_type value) ENTT_NOEXCEPT {
return ((begin += value) != end && !valid()) ? ++(*this) : *this;
}
Iterator operator+(difference_type value) noexcept {
Iterator operator+(difference_type value) ENTT_NOEXCEPT {
return Iterator{unchecked, extent, begin+value, end};
}
bool operator==(const Iterator &other) const noexcept {
bool operator==(const Iterator &other) const ENTT_NOEXCEPT {
return other.begin == begin;
}
bool operator!=(const Iterator &other) const noexcept {
bool operator!=(const Iterator &other) const ENTT_NOEXCEPT {
return !(*this == other);
}
value_type operator*() const noexcept {
value_type operator*() const ENTT_NOEXCEPT {
return *begin;
}
@@ -449,7 +450,7 @@ class View final {
underlying_iterator_type end;
};
View(pool_type<Component> &... pools) noexcept
View(pool_type<Component> &... pools) ENTT_NOEXCEPT
: pools{pools...}, view{nullptr}, unchecked{}
{
reset();
@@ -467,7 +468,7 @@ public:
* @brief Estimates the number of entities that have the given components.
* @return Estimated number of entities that have the given components.
*/
size_type size() const noexcept {
size_type size() const ENTT_NOEXCEPT {
return view->size();
}
@@ -485,7 +486,7 @@ public:
*
* @return An iterator to the first entity that has the given components.
*/
iterator_type begin() const noexcept {
iterator_type begin() const ENTT_NOEXCEPT {
const auto extent = std::min({ std::get<pool_type<Component> &>(pools).extent()... });
return Iterator{unchecked, extent, view->begin(), view->end()};
}
@@ -505,7 +506,7 @@ public:
* @return An iterator to the entity following the last entity that has the
* given components.
*/
iterator_type end() const noexcept {
iterator_type end() const ENTT_NOEXCEPT {
const auto extent = std::min({ std::get<pool_type<Component> &>(pools).extent()... });
return Iterator{unchecked, extent, view->end(), view->end()};
}
@@ -515,7 +516,7 @@ public:
* @param entity A valid entity identifier.
* @return True if the view contains the given entity, false otherwise.
*/
bool contains(entity_type entity) const noexcept {
bool contains(entity_type entity) const ENTT_NOEXCEPT {
const auto extent = std::min({ std::get<pool_type<Component> &>(pools).extent()... });
const auto sz = size_type(entity & traits_type::entity_mask);
auto pos = unchecked.size();
@@ -545,7 +546,7 @@ public:
* @return The component assigned to the entity.
*/
template<typename Comp>
const Comp & get(entity_type entity) const noexcept {
const Comp & get(entity_type entity) const ENTT_NOEXCEPT {
assert(contains(entity));
return std::get<pool_type<Comp> &>(pools).get(entity);
}
@@ -568,7 +569,7 @@ public:
* @return The component assigned to the entity.
*/
template<typename Comp>
Comp & get(entity_type entity) noexcept {
Comp & get(entity_type entity) ENTT_NOEXCEPT {
return const_cast<Comp &>(const_cast<const View *>(this)->get<Comp>(entity));
}
@@ -591,7 +592,7 @@ public:
*/
template<typename... Comp>
std::enable_if_t<(sizeof...(Comp) > 1), std::tuple<const Comp &...>>
get(entity_type entity) const noexcept {
get(entity_type entity) const ENTT_NOEXCEPT {
assert(contains(entity));
return std::tuple<const Comp &...>{get<Comp>(entity)...};
}
@@ -615,7 +616,7 @@ public:
*/
template<typename... Comp>
std::enable_if_t<(sizeof...(Comp) > 1), std::tuple<Comp &...>>
get(entity_type entity) noexcept {
get(entity_type entity) ENTT_NOEXCEPT {
assert(contains(entity));
return std::tuple<Comp &...>{get<Comp>(entity)...};
}
@@ -760,7 +761,7 @@ class View<Entity, Component> final {
using view_type = SparseSet<Entity>;
using pool_type = SparseSet<Entity, Component>;
View(pool_type &pool) noexcept
View(pool_type &pool) ENTT_NOEXCEPT
: pool{pool}
{}
@@ -778,7 +779,7 @@ public:
* @brief Returns the number of entities that have the given component.
* @return Number of entities that have the given component.
*/
size_type size() const noexcept {
size_type size() const ENTT_NOEXCEPT {
return pool.size();
}
@@ -794,7 +795,7 @@ public:
*
* @return A pointer to the array of components.
*/
raw_type * raw() noexcept {
raw_type * raw() ENTT_NOEXCEPT {
return pool.raw();
}
@@ -810,7 +811,7 @@ public:
*
* @return A pointer to the array of components.
*/
const raw_type * raw() const noexcept {
const raw_type * raw() const ENTT_NOEXCEPT {
return pool.raw();
}
@@ -826,7 +827,7 @@ public:
*
* @return A pointer to the array of entities.
*/
const entity_type * data() const noexcept {
const entity_type * data() const ENTT_NOEXCEPT {
return pool.data();
}
@@ -844,7 +845,7 @@ public:
*
* @return An iterator to the first entity that has the given component.
*/
iterator_type begin() const noexcept {
iterator_type begin() const ENTT_NOEXCEPT {
return pool.view_type::begin();
}
@@ -863,7 +864,7 @@ public:
* @return An iterator to the entity following the last entity that has the
* given component.
*/
iterator_type end() const noexcept {
iterator_type end() const ENTT_NOEXCEPT {
return pool.view_type::end();
}
@@ -872,7 +873,7 @@ public:
* @param entity A valid entity identifier.
* @return True if the view contains the given entity, false otherwise.
*/
bool contains(entity_type entity) const noexcept {
bool contains(entity_type entity) const ENTT_NOEXCEPT {
return pool.has(entity) && (pool.data()[pool.view_type::get(entity)] == entity);
}
@@ -891,7 +892,7 @@ public:
* @param entity A valid entity identifier.
* @return The component assigned to the entity.
*/
const Component & get(entity_type entity) const noexcept {
const Component & get(entity_type entity) const ENTT_NOEXCEPT {
assert(contains(entity));
return pool.get(entity);
}
@@ -911,7 +912,7 @@ public:
* @param entity A valid entity identifier.
* @return The component assigned to the entity.
*/
Component & get(entity_type entity) noexcept {
Component & get(entity_type entity) ENTT_NOEXCEPT {
return const_cast<Component &>(const_cast<const View *>(this)->get(entity));
}
@@ -1012,7 +1013,7 @@ class RawView final {
using view_type = SparseSet<Entity>;
using pool_type = SparseSet<Entity, Component>;
RawView(pool_type &pool) noexcept
RawView(pool_type &pool) ENTT_NOEXCEPT
: pool{pool}
{}
@@ -1030,7 +1031,7 @@ public:
* @brief Returns the number of instances of the given type.
* @return Number of instances of the given component.
*/
size_type size() const noexcept {
size_type size() const ENTT_NOEXCEPT {
return pool.size();
}
@@ -1046,7 +1047,7 @@ public:
*
* @return A pointer to the array of components.
*/
raw_type * raw() noexcept {
raw_type * raw() ENTT_NOEXCEPT {
return pool.raw();
}
@@ -1062,7 +1063,7 @@ public:
*
* @return A pointer to the array of components.
*/
const raw_type * raw() const noexcept {
const raw_type * raw() const ENTT_NOEXCEPT {
return pool.raw();
}
@@ -1078,7 +1079,7 @@ public:
*
* @return A pointer to the array of entities.
*/
const entity_type * data() const noexcept {
const entity_type * data() const ENTT_NOEXCEPT {
return pool.data();
}
@@ -1094,7 +1095,7 @@ public:
*
* @return An iterator to the first instance of the given type.
*/
iterator_type begin() const noexcept {
iterator_type begin() const ENTT_NOEXCEPT {
return pool.begin();
}
@@ -1113,7 +1114,7 @@ public:
* @return An iterator to the element following the last instance of the
* given type.
*/
iterator_type end() const noexcept {
iterator_type end() const ENTT_NOEXCEPT {
return pool.end();
}

View File

@@ -5,6 +5,7 @@
#include <memory>
#include <utility>
#include <cassert>
#include "../config/config.h"
namespace entt {
@@ -35,7 +36,7 @@ struct ServiceLocator final {
* @brief Tests if a valid service implementation is set.
* @return True if the service is set, false otherwise.
*/
inline static bool empty() noexcept {
inline static bool empty() ENTT_NOEXCEPT {
return !static_cast<bool>(service);
}
@@ -49,7 +50,7 @@ struct ServiceLocator final {
*
* @return A reference to the service implementation currently set, if any.
*/
inline static std::weak_ptr<Service> get() noexcept {
inline static std::weak_ptr<Service> get() ENTT_NOEXCEPT {
return service;
}
@@ -67,7 +68,7 @@ struct ServiceLocator final {
*
* @return A reference to the service implementation currently set, if any.
*/
inline static Service & ref() noexcept {
inline static Service & ref() ENTT_NOEXCEPT {
return *service;
}

View File

@@ -5,6 +5,7 @@
#include <type_traits>
#include <functional>
#include <utility>
#include "../config/config.h"
namespace entt {
@@ -123,7 +124,7 @@ protected:
* The function is idempotent and it does nothing if the process isn't
* alive.
*/
void succeed() noexcept {
void succeed() ENTT_NOEXCEPT {
if(alive()) {
current = State::SUCCEEDED;
}
@@ -135,7 +136,7 @@ protected:
* The function is idempotent and it does nothing if the process isn't
* alive.
*/
void fail() noexcept {
void fail() ENTT_NOEXCEPT {
if(alive()) {
current = State::FAILED;
}
@@ -147,7 +148,7 @@ protected:
* The function is idempotent and it does nothing if the process isn't
* running.
*/
void pause() noexcept {
void pause() ENTT_NOEXCEPT {
if(current == State::RUNNING) {
current = State::PAUSED;
}
@@ -159,7 +160,7 @@ protected:
* The function is idempotent and it does nothing if the process isn't
* paused.
*/
void unpause() noexcept {
void unpause() ENTT_NOEXCEPT {
if(current == State::PAUSED) {
current = State::RUNNING;
}
@@ -170,7 +171,7 @@ public:
using delta_type = Delta;
/*! @brief Default destructor. */
virtual ~Process() noexcept {
virtual ~Process() ENTT_NOEXCEPT {
static_assert(std::is_base_of<Process, Derived>::value, "!");
}
@@ -182,7 +183,7 @@ public:
*
* @param immediately Requests an immediate operation.
*/
void abort(bool immediately = false) noexcept {
void abort(bool immediately = false) ENTT_NOEXCEPT {
if(alive()) {
current = State::ABORTED;
@@ -196,7 +197,7 @@ public:
* @brief Returns true if a process is either running or paused.
* @return True if the process is still alive, false otherwise.
*/
bool alive() const noexcept {
bool alive() const ENTT_NOEXCEPT {
return current == State::RUNNING || current == State::PAUSED;
}
@@ -204,7 +205,7 @@ public:
* @brief Returns true if a process is already terminated.
* @return True if the process is terminated, false otherwise.
*/
bool dead() const noexcept {
bool dead() const ENTT_NOEXCEPT {
return current == State::FINISHED;
}
@@ -212,7 +213,7 @@ public:
* @brief Returns true if a process is currently paused.
* @return True if the process is paused, false otherwise.
*/
bool paused() const noexcept {
bool paused() const ENTT_NOEXCEPT {
return current == State::PAUSED;
}
@@ -220,7 +221,7 @@ public:
* @brief Returns true if a process terminated with errors.
* @return True if the process terminated with errors, false otherwise.
*/
bool rejected() const noexcept {
bool rejected() const ENTT_NOEXCEPT {
return stopped;
}

View File

@@ -8,6 +8,7 @@
#include <iterator>
#include <algorithm>
#include <type_traits>
#include "../config/config.h"
#include "process.hpp"
@@ -130,7 +131,7 @@ public:
using size_type = typename std::vector<ProcessHandler>::size_type;
/*! @brief Default constructor. */
Scheduler() noexcept= default;
Scheduler() ENTT_NOEXCEPT = default;
/*! @brief Copying a scheduler isn't allowed. */
Scheduler(const Scheduler &) = delete;
@@ -146,7 +147,7 @@ public:
* @brief Number of processes currently scheduled.
* @return Number of processes currently scheduled.
*/
size_type size() const noexcept {
size_type size() const ENTT_NOEXCEPT {
return handlers.size();
}
@@ -154,7 +155,7 @@ public:
* @brief Returns true if at least a process is currently scheduled.
* @return True if there are scheduled processes, false otherwise.
*/
bool empty() const noexcept {
bool empty() const ENTT_NOEXCEPT {
return handlers.empty();
}

View File

@@ -6,6 +6,7 @@
#include <utility>
#include <type_traits>
#include <unordered_map>
#include "../config/config.h"
#include "../core/hashed_string.hpp"
#include "handle.hpp"
#include "loader.hpp"
@@ -38,20 +39,20 @@ public:
ResourceCache() = default;
/*! @brief Copying a cache isn't allowed. */
ResourceCache(const ResourceCache &) noexcept = delete;
ResourceCache(const ResourceCache &) ENTT_NOEXCEPT = delete;
/*! @brief Default move constructor. */
ResourceCache(ResourceCache &&) noexcept = default;
ResourceCache(ResourceCache &&) ENTT_NOEXCEPT = default;
/*! @brief Copying a cache isn't allowed. @return This cache. */
ResourceCache & operator=(const ResourceCache &) noexcept = delete;
ResourceCache & operator=(const ResourceCache &) ENTT_NOEXCEPT = delete;
/*! @brief Default move assignment operator. @return This cache. */
ResourceCache & operator=(ResourceCache &&) noexcept = default;
ResourceCache & operator=(ResourceCache &&) ENTT_NOEXCEPT = default;
/**
* @brief Number of resources managed by a cache.
* @return Number of resources currently stored.
*/
size_type size() const noexcept {
size_type size() const ENTT_NOEXCEPT {
return resources.size();
}
@@ -59,7 +60,7 @@ public:
* @brief Returns true if a cache contains no resources, false otherwise.
* @return True if the cache contains no resources, false otherwise.
*/
bool empty() const noexcept {
bool empty() const ENTT_NOEXCEPT {
return resources.empty();
}
@@ -69,7 +70,7 @@ public:
* Handles are not invalidated and the memory used by a resource isn't
* freed as long as at least a handle keeps the resource itself alive.
*/
void clear() noexcept {
void clear() ENTT_NOEXCEPT {
resources.clear();
}
@@ -169,7 +170,7 @@ public:
* @param id Unique resource identifier.
* @return True if the cache contains the resource, false otherwise.
*/
bool contains(resource_type id) const noexcept {
bool contains(resource_type id) const ENTT_NOEXCEPT {
return (resources.find(id) != resources.cend());
}
@@ -181,7 +182,7 @@ public:
*
* @param id Unique resource identifier.
*/
void discard(resource_type id) noexcept {
void discard(resource_type id) ENTT_NOEXCEPT {
auto it = resources.find(id);
if(it != resources.end()) {

View File

@@ -5,6 +5,7 @@
#include <memory>
#include <utility>
#include <cassert>
#include "../config/config.h"
namespace entt {
@@ -31,20 +32,20 @@ class ResourceHandle final {
/*! @brief Resource handles are friends of their caches. */
friend class ResourceCache<Resource>;
ResourceHandle(std::shared_ptr<Resource> res) noexcept
ResourceHandle(std::shared_ptr<Resource> res) ENTT_NOEXCEPT
: resource{std::move(res)}
{}
public:
/*! @brief Default copy constructor. */
ResourceHandle(const ResourceHandle &) noexcept = default;
ResourceHandle(const ResourceHandle &) ENTT_NOEXCEPT = default;
/*! @brief Default move constructor. */
ResourceHandle(ResourceHandle &&) noexcept = default;
ResourceHandle(ResourceHandle &&) ENTT_NOEXCEPT = default;
/*! @brief Default copy assignment operator. @return This handle. */
ResourceHandle & operator=(const ResourceHandle &) noexcept = default;
ResourceHandle & operator=(const ResourceHandle &) ENTT_NOEXCEPT = default;
/*! @brief Default move assignment operator. @return This handle. */
ResourceHandle & operator=(ResourceHandle &&) noexcept = default;
ResourceHandle & operator=(ResourceHandle &&) ENTT_NOEXCEPT = default;
/**
* @brief Gets a reference to the managed resource.
@@ -56,7 +57,7 @@ public:
*
* @return A reference to the managed resource.
*/
const Resource & get() const noexcept {
const Resource & get() const ENTT_NOEXCEPT {
assert(static_cast<bool>(resource));
return *resource;
}
@@ -69,7 +70,7 @@ public:
* An assertion will abort the execution at runtime in debug mode if the
* handle is empty.
*/
inline operator const Resource & () const noexcept { return get(); }
inline operator const Resource & () const ENTT_NOEXCEPT { return get(); }
/**
* @brief Dereferences a handle to obtain the managed resource.
@@ -81,7 +82,7 @@ public:
*
* @return A reference to the managed resource.
*/
inline const Resource & operator *() const noexcept { return get(); }
inline const Resource & operator *() const ENTT_NOEXCEPT { return get(); }
/**
* @brief Gets a pointer to the managed resource from a handle .
@@ -94,7 +95,7 @@ public:
* @return A pointer to the managed resource or `nullptr` if the handle
* contains no resource at all.
*/
inline const Resource * operator ->() const noexcept {
inline const Resource * operator ->() const ENTT_NOEXCEPT {
assert(static_cast<bool>(resource));
return resource.get();
}

View File

@@ -3,6 +3,7 @@
#include <utility>
#include "../config/config.h"
namespace entt {
@@ -36,7 +37,7 @@ class Delegate<Ret(Args...)> final {
using proto_type = Ret(*)(void *, Args...);
using stub_type = std::pair<void *, proto_type>;
static Ret fallback(void *, Args...) noexcept { return {}; }
static Ret fallback(void *, Args...) ENTT_NOEXCEPT { return {}; }
template<Ret(*Function)(Args...)>
static Ret proto(void *, Args... args) {
@@ -50,7 +51,7 @@ class Delegate<Ret(Args...)> final {
public:
/*! @brief Default constructor. */
Delegate() noexcept
Delegate() ENTT_NOEXCEPT
: stub{std::make_pair(nullptr, &fallback)}
{}
@@ -59,7 +60,7 @@ public:
* @tparam Function A valid free function pointer.
*/
template<Ret(*Function)(Args...)>
void connect() noexcept {
void connect() ENTT_NOEXCEPT {
stub = std::make_pair(nullptr, &proto<Function>);
}
@@ -75,7 +76,7 @@ public:
* @param instance A valid instance of type pointer to `Class`.
*/
template<typename Class, Ret(Class::*Member)(Args...)>
void connect(Class *instance) noexcept {
void connect(Class *instance) ENTT_NOEXCEPT {
stub = std::make_pair(instance, &proto<Class, Member>);
}
@@ -84,7 +85,7 @@ public:
*
* After a reset, a delegate can be safely invoked with no effect.
*/
void reset() noexcept {
void reset() ENTT_NOEXCEPT {
stub = std::make_pair(nullptr, &fallback);
}
@@ -105,7 +106,7 @@ public:
* @param other Delegate with which to compare.
* @return True if the two delegates are identical, false otherwise.
*/
bool operator==(const Delegate<Ret(Args...)> &other) const noexcept {
bool operator==(const Delegate<Ret(Args...)> &other) const ENTT_NOEXCEPT {
return stub.first == other.stub.first && stub.second == other.stub.second;
}
@@ -126,7 +127,7 @@ private:
* @return True if the two delegates are different, false otherwise.
*/
template<typename Ret, typename... Args>
bool operator!=(const Delegate<Ret(Args...)> &lhs, const Delegate<Ret(Args...)> &rhs) noexcept {
bool operator!=(const Delegate<Ret(Args...)> &lhs, const Delegate<Ret(Args...)> &rhs) ENTT_NOEXCEPT {
return !(lhs == rhs);
}

View File

@@ -8,6 +8,7 @@
#include <cstdint>
#include <algorithm>
#include <type_traits>
#include "../config/config.h"
#include "../core/family.hpp"
#include "sigh.hpp"
@@ -53,7 +54,7 @@ class Dispatcher final {
events[curr].clear();
}
inline sink_type sink() noexcept {
inline sink_type sink() ENTT_NOEXCEPT {
return signal.sink();
}
@@ -111,7 +112,7 @@ public:
* @return A temporary sink object.
*/
template<typename Event>
inline sink_type<Event> sink() noexcept {
inline sink_type<Event> sink() ENTT_NOEXCEPT {
return wrapper<Event>().sink();
}

View File

@@ -10,6 +10,7 @@
#include <memory>
#include <vector>
#include <list>
#include "../config/config.h"
namespace entt {
@@ -40,8 +41,8 @@ template<typename Derived>
class Emitter {
struct BaseHandler {
virtual ~BaseHandler() = default;
virtual bool empty() const noexcept = 0;
virtual void clear() noexcept = 0;
virtual bool empty() const ENTT_NOEXCEPT = 0;
virtual void clear() ENTT_NOEXCEPT = 0;
};
template<typename Event>
@@ -51,14 +52,14 @@ class Emitter {
using container_type = std::list<element_type>;
using connection_type = typename container_type::iterator;
bool empty() const noexcept override {
bool empty() const ENTT_NOEXCEPT override {
auto pred = [](auto &&element) { return element.first; };
return std::all_of(onceL.cbegin(), onceL.cend(), pred) &&
std::all_of(onL.cbegin(), onL.cend(), pred);
}
void clear() noexcept override {
void clear() ENTT_NOEXCEPT override {
if(publishing) {
auto func = [](auto &&element) { element.first = true; };
std::for_each(onceL.begin(), onceL.end(), func);
@@ -77,7 +78,7 @@ class Emitter {
return onL.emplace(onL.cend(), false, std::move(listener));
}
void erase(connection_type conn) noexcept {
void erase(connection_type conn) ENTT_NOEXCEPT {
conn->first = true;
if(!publishing) {
@@ -111,19 +112,19 @@ class Emitter {
container_type onL{};
};
static std::size_t next() noexcept {
static std::size_t next() ENTT_NOEXCEPT {
static std::size_t counter = 0;
return counter++;
}
template<typename>
static std::size_t type() noexcept {
static std::size_t type() ENTT_NOEXCEPT {
static std::size_t value = next();
return value;
}
template<typename Event>
Handler<Event> & handler() noexcept {
Handler<Event> & handler() ENTT_NOEXCEPT {
const std::size_t family = type<Event>();
if(!(family < handlers.size())) {
@@ -157,7 +158,7 @@ public:
friend class Emitter;
/*! @brief Default constructor. */
Connection() noexcept = default;
Connection() ENTT_NOEXCEPT = default;
/**
* @brief Creates a connection that wraps its underlying instance.
@@ -186,10 +187,10 @@ public:
};
/*! @brief Default constructor. */
Emitter() noexcept = default;
Emitter() ENTT_NOEXCEPT = default;
/*! @brief Default destructor. */
virtual ~Emitter() noexcept {
virtual ~Emitter() ENTT_NOEXCEPT {
static_assert(std::is_base_of<Emitter<Derived>, Derived>::value, "!");
}
@@ -279,7 +280,7 @@ public:
* @param conn A valid connection.
*/
template<typename Event>
void erase(Connection<Event> conn) noexcept {
void erase(Connection<Event> conn) ENTT_NOEXCEPT {
handler<Event>().erase(std::move(conn));
}
@@ -292,7 +293,7 @@ public:
* @tparam Event Type of event to reset.
*/
template<typename Event>
void clear() noexcept {
void clear() ENTT_NOEXCEPT {
handler<Event>().clear();
}
@@ -302,7 +303,7 @@ public:
* All the connections previously returned are invalidated. Using them
* results in undefined behavior.
*/
void clear() noexcept {
void clear() ENTT_NOEXCEPT {
std::for_each(handlers.begin(), handlers.end(),
[](auto &&handler) { if(handler) { handler->clear(); } });
}
@@ -313,7 +314,7 @@ public:
* @return True if there are no listeners registered, false otherwise.
*/
template<typename Event>
bool empty() const noexcept {
bool empty() const ENTT_NOEXCEPT {
const std::size_t family = type<Event>();
return (!(family < handlers.size()) ||
@@ -325,7 +326,7 @@ public:
* @brief Checks if there are listeners registered with the event emitter.
* @return True if there are no listeners registered, false otherwise.
*/
bool empty() const noexcept {
bool empty() const ENTT_NOEXCEPT {
return std::all_of(handlers.cbegin(), handlers.cend(),
[](auto &&handler) { return !handler || handler->empty(); });
}

View File

@@ -5,6 +5,7 @@
#include <algorithm>
#include <utility>
#include <vector>
#include "../config/config.h"
namespace entt {
@@ -52,14 +53,14 @@ struct Invoker<void(Args...), Collector> {
template<typename Ret>
struct NullCollector final {
using result_type = Ret;
bool operator()(result_type) const noexcept { return true; }
bool operator()(result_type) const ENTT_NOEXCEPT { return true; }
};
template<>
struct NullCollector<void> final {
using result_type = void;
bool operator()() const noexcept { return true; }
bool operator()() const ENTT_NOEXCEPT { return true; }
};
@@ -273,7 +274,7 @@ public:
* @brief Number of listeners connected to the signal.
* @return Number of listeners currently connected.
*/
size_type size() const noexcept {
size_type size() const ENTT_NOEXCEPT {
return calls.size();
}
@@ -281,7 +282,7 @@ public:
* @brief Returns false if at least a listener is connected to the signal.
* @return True if the signal has no listeners connected, false otherwise.
*/
bool empty() const noexcept {
bool empty() const ENTT_NOEXCEPT {
return calls.empty();
}
@@ -347,7 +348,7 @@ public:
* @param other Signal with which to compare.
* @return True if the two signals are identical, false otherwise.
*/
bool operator==(const SigH &other) const noexcept {
bool operator==(const SigH &other) const ENTT_NOEXCEPT {
return std::equal(calls.cbegin(), calls.cend(), other.calls.cbegin(), other.calls.cend());
}
@@ -369,7 +370,7 @@ private:
* @return True if the two signals are different, false otherwise.
*/
template<typename Ret, typename... Args>
bool operator!=(const SigH<Ret(Args...)> &lhs, const SigH<Ret(Args...)> &rhs) noexcept {
bool operator!=(const SigH<Ret(Args...)> &lhs, const SigH<Ret(Args...)> &rhs) ENTT_NOEXCEPT {
return !(lhs == rhs);
}