fix bugs in static_variant
This commit is contained in:
parent
0caac3fee9
commit
3a120c0f7f
1 changed files with 3 additions and 2 deletions
|
|
@ -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;}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue