5 #include <l4/cxx/type_traits> 10 template<
typename T >
11 class Static_container
16 void *
operator new (size_t,
void *p)
throw() {
return p; }
17 void operator delete (
void *) {}
19 template<
typename ...Args>
20 X(Args && ...a) : T(
cxx::forward<Args>(a)...) {}
24 void operator = (Static_container
const &) =
delete;
25 Static_container(Static_container
const &) =
delete;
26 Static_container() =
default;
28 T *
get() {
return reinterpret_cast<X*
>(_s); }
29 T *operator -> () {
return get(); }
30 T &operator * () {
return *
get(); }
31 operator T* () {
return get(); }
34 {
new (
reinterpret_cast<void*
>(_s)) X; }
36 template<
typename ...Args >
37 void construct(Args && ...args)
38 {
new (
reinterpret_cast<void*
>(_s)) X(cxx::forward<Args>(args)...); }
41 char _s[
sizeof(X)] __attribute__((aligned(__alignof(X))));