A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of https://framagit.org/simgrid/simgrid into CRTP
[simgrid.git]
/
include
/
xbt
/
Extendable.hpp
diff --git
a/include/xbt/Extendable.hpp
b/include/xbt/Extendable.hpp
index
d90314d
..
37a7d41
100644
(file)
--- a/
include/xbt/Extendable.hpp
+++ b/
include/xbt/Extendable.hpp
@@
-1,4
+1,4
@@
-/* Copyright (c) 2015. The SimGrid Team.
+/* Copyright (c) 2015
-2019
. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
@@
-22,11
+22,11
@@
class Extension {
static const std::size_t INVALID_ID = std::numeric_limits<std::size_t>::max();
std::size_t id_;
friend class Extendable<T>;
static const std::size_t INVALID_ID = std::numeric_limits<std::size_t>::max();
std::size_t id_;
friend class Extendable<T>;
- constexpr Extension(std::size_t id) : id_(id) {}
+
explicit
constexpr Extension(std::size_t id) : id_(id) {}
public:
explicit constexpr Extension() : id_(INVALID_ID) {}
std::size_t id() const { return id_; }
public:
explicit constexpr Extension() : id_(INVALID_ID) {}
std::size_t id() const { return id_; }
- bool valid() { return id_ != INVALID_ID; }
+ bool valid()
const
{ return id_ != INVALID_ID; }
};
/** An Extendable is an object that you can extend with external elements.
};
/** An Extendable is an object that you can extend with external elements.
@@
-48,7
+48,6
@@
template<class T>
class Extendable {
private:
static std::vector<void(*)(void*)> deleters_;
class Extendable {
private:
static std::vector<void(*)(void*)> deleters_;
-protected:
std::vector<void*> extensions_;
public:
static size_t extension_create(void (*deleter)(void*))
std::vector<void*> extensions_;
public:
static size_t extension_create(void (*deleter)(void*))
@@
-65,9
+64,11
@@
public:
template<class U> static
Extension<T,U> extension_create()
{
template<class U> static
Extension<T,U> extension_create()
{
- return
extension_create([](void* p){ delete static_cast<U*>(p); }
);
+ return
Extension<T, U>(extension_create([](void* p) { delete static_cast<U*>(p); })
);
}
Extendable() : extensions_(deleters_.size(), nullptr) {}
}
Extendable() : extensions_(deleters_.size(), nullptr) {}
+ Extendable(const Extendable&) = delete;
+ Extendable& operator=(const Extendable&) = delete;
~Extendable()
{
/* Call destructors in reverse order of their registrations
~Extendable()
{
/* Call destructors in reverse order of their registrations
@@
-82,7
+83,7
@@
public:
}
// Type-unsafe versions of the facet access methods:
}
// Type-unsafe versions of the facet access methods:
- void* extension(std::size_t rank)
+ void* extension(std::size_t rank)
const
{
if (rank >= extensions_.size())
return nullptr;
{
if (rank >= extensions_.size())
return nullptr;
@@
-100,11
+101,7
@@
public:
}
// Type safe versions of the facet access methods:
}
// Type safe versions of the facet access methods:
- template<class U>
- U* extension(Extension<T,U> rank)
- {
- return static_cast<U*>(extension(rank.id()));
- }
+ template <class U> U* extension(Extension<T, U> rank) const { return static_cast<U*>(extension(rank.id())); }
template<class U>
void extension_set(Extension<T,U> rank, U* value, bool use_dtor = true)
{
template<class U>
void extension_set(Extension<T,U> rank, U* value, bool use_dtor = true)
{
@@
-112,13
+109,11
@@
public:
}
// Convenience extension access when the type has a associated EXTENSION ID:
}
// Convenience extension access when the type has a associated EXTENSION ID:
- template
<class U> U* extension()
{ return extension<U>(U::EXTENSION_ID); }
+ template
<class U> U* extension() const
{ return extension<U>(U::EXTENSION_ID); }
template<class U> void extension_set(U* p) { extension_set<U>(U::EXTENSION_ID, p); }
};
template<class U> void extension_set(U* p) { extension_set<U>(U::EXTENSION_ID, p); }
};
-template<class T>
-std::vector<void(*)(void*)> Extendable<T>::deleters_ = {};
-
+template <class T> std::vector<void (*)(void*)> Extendable<T>::deleters_;
}
}
}
}