mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-11-28 17:40:01 +08:00
51 lines
805 B
C++
51 lines
805 B
C++
|
// CODYlib -*- mode:c++ -*-
|
||
|
// Copyright (C) 2020 Nathan Sidwell, nathan@acm.org
|
||
|
// License: Apache v2.0
|
||
|
|
||
|
// Cody
|
||
|
#include "internal.hh"
|
||
|
|
||
|
namespace Cody {
|
||
|
|
||
|
void Packet::Destroy ()
|
||
|
{
|
||
|
switch (cat)
|
||
|
{
|
||
|
case STRING:
|
||
|
// Silly scope destructor name rules
|
||
|
using S = std::string;
|
||
|
string.~S ();
|
||
|
break;
|
||
|
|
||
|
case VECTOR:
|
||
|
using V = std::vector<std::string>;
|
||
|
vector.~V ();
|
||
|
break;
|
||
|
|
||
|
default:;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void Packet::Create (Packet &&t)
|
||
|
{
|
||
|
cat = t.cat;
|
||
|
code = t.code;
|
||
|
request = t.request;
|
||
|
switch (cat)
|
||
|
{
|
||
|
case STRING:
|
||
|
new (&string) std::string (std::move (t.string));
|
||
|
break;
|
||
|
|
||
|
case VECTOR:
|
||
|
new (&vector) std::vector<std::string> (std::move (t.vector));
|
||
|
break;
|
||
|
|
||
|
default:
|
||
|
integer = t.integer;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|