blob: edd8c869e862aad110ca749fdb12bd520d48deac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
/**
** \file misc/symbol.cc
** \brief Implementation of misc::symbol.
*/
#include <sstream>
#include <string>
#include <misc/symbol.hh>
namespace misc
{
symbol::symbol(const std::string& s)
: unique<std::string>(s)
{}
symbol::symbol(const char* s)
: unique<std::string>(std::string(s))
{}
symbol symbol::fresh() { return fresh("a"); }
symbol symbol::fresh(const symbol& s)
{
/// Counter of unique symbols.
static unsigned counter_ = 0;
std::string str = s.get() + "_" + std::to_string(counter_);
++counter_;
return symbol(str);
}
} // namespace misc
|