-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsli_string.h
59 lines (50 loc) · 839 Bytes
/
sli_string.h
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* lockptr.h
*
* This file is part of NEST
*
* Copyright (C) 2004 by
* The NEST Initiative
*
* See the file AUTHORS for details.
*
* Permission is granted to compile and modify
* this file for non-commercial use.
* See the file LICENSE for details.
*
*/
#ifndef SLI_STRING_H
#define SLI_STRING_H
#include <cassert>
#include <string>
/**
*/
namespace sli3
{
class SLIString: public std::string
{
mutable size_t refs_;
public:
SLIString(){}
SLIString(const std::string &s)
:std::string(s){}
size_t add_reference() const
{
return ++refs_;
}
size_t references() const
{
return refs_;
}
size_t remove_reference()
{
if( --refs_==0)
{
delete this;
return 0;
}
return refs_;
}
};
}
#endif