fix bugs in static_variant

This commit is contained in:
Daniel Larimer 2015-03-05 08:58:29 -05:00
parent 0caac3fee9
commit 3a120c0f7f

View file

@ -80,7 +80,7 @@ struct storage_ops<N, T, Ts...> {
} }
static void con(int n, void *data) { static void con(int n, void *data) {
if(n == N) new(reinterpret_cast<T*>(data)) T(); if(n == N) new(reinterpret_cast<T*>(data)) T();
else storage_ops<N + 1, Ts...>::del(n, data); else storage_ops<N + 1, Ts...>::con(n, data);
} }
template<typename visitor> template<typename visitor>
@ -316,7 +316,8 @@ public:
void set_which( int w ) { void set_which( int w ) {
this->~static_variant(); this->~static_variant();
impl::storage_ops<0, Types...>::con(_tag, storage); _tag = w;
impl::storage_ops<0, Types...>::con(_tag, storage);
} }
int which() const {return _tag;} int which() const {return _tag;}