forked from boostorg/concept_check
changed to John's version of static_object
[SVN r9664]
This commit is contained in:
@@ -40,30 +40,16 @@ namespace boost {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// This is a helper class that provides a way to get a reference to
|
// This is a helper class that provides a way to get a reference to
|
||||||
// an object.
|
// an object. The get() function will never be called at run-time
|
||||||
|
// (nothing in this file will) so this seemingly very bad function
|
||||||
|
// is really quite innocent. The name of this class needs to be
|
||||||
|
// changed.
|
||||||
template <class T>
|
template <class T>
|
||||||
class static_object {
|
class static_object {
|
||||||
public:
|
public:
|
||||||
static T& get() {
|
static T& get() {
|
||||||
detail::dummy_constructor d;
|
char d[sizeof(T)];
|
||||||
static T x(d);
|
return *reinterpret_cast<T*>(d);
|
||||||
return x;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template <>
|
|
||||||
class static_object<bool> {
|
|
||||||
public:
|
|
||||||
static bool& get() {
|
|
||||||
static bool b;
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template <>
|
|
||||||
class static_object<int> {
|
|
||||||
public:
|
|
||||||
static int& get() {
|
|
||||||
static int b;
|
|
||||||
return b;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user