Commit 68493de7 authored by Gauthier Quesnel's avatar Gauthier Quesnel
Browse files

union: fixes bad contructor prototype

parent b0b32180
......@@ -57,31 +57,31 @@ public:
tag type{ tag::integer };
parameter()
tagged_union()
: l(0)
{}
parameter(int value_)
tagged_union(int value_)
: l(value_)
, type(tag::integer)
{}
parameter(double value_)
tagged_union(double value_)
: d(value_)
, type(tag::real)
{}
parameter(std::string value_)
tagged_union(std::string value_)
: s(std::move(value_))
, type(tag::string)
{}
parameter(const char* value_)
tagged_union(const char* value_)
: s(value_)
, type(tag::string)
{}
parameter(const parameter& w)
tagged_union(const tagged_union& w)
: type(w.type)
{
switch (w.type) {
......@@ -97,7 +97,7 @@ public:
}
}
parameter(parameter&& w)
tagged_union(tagged_union&& w)
: type(w.type)
{
switch (w.type) {
......@@ -116,7 +116,7 @@ public:
w.l = 0;
}
parameter& operator=(const parameter& w)
tagged_union& operator=(const tagged_union& w)
{
if (type == tag::string and w.type == tag::string) {
s = w.s;
......@@ -144,7 +144,7 @@ public:
return *this;
}
parameter& operator=(parameter&& w)
tagged_union& operator=(tagged_union&& w)
{
if (type == tag::string and w.type == tag::string) {
new (&s) std::string(w.s);
......@@ -178,7 +178,7 @@ public:
return *this;
}
parameter& operator=(double value)
tagged_union& operator=(double value)
{
if (type == tag::real) {
d = value;
......@@ -196,7 +196,7 @@ public:
return *this;
}
parameter& operator=(int value)
tagged_union& operator=(int value)
{
if (type == tag::integer) {
l = value;
......@@ -214,7 +214,7 @@ public:
return *this;
}
parameter& operator=(const std::string& value)
tagged_union& operator=(const std::string& value)
{
if (type == tag::string) {
s = value;
......@@ -232,7 +232,7 @@ public:
return *this;
}
parameter& operator=(const char* value)
tagged_union& operator=(const char* value)
{
if (type == tag::string) {
s = value;
......@@ -250,7 +250,7 @@ public:
return *this;
}
~parameter() noexcept
~tagged_union() noexcept
{
if (type == tag::string) {
using std::string;
......@@ -258,9 +258,9 @@ public:
}
}
void swap(parameter& p)
void swap(tagged_union& p)
{
parameter copy(*this);
tagged_union copy(*this);
*this = p;
p = copy;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment