#include <string>
namespace my_ns
{
namespace miruna
{
template<typename T>
struct static_vars_holder
{
static int i1;
static double d1;
static std::string s1;
};
template<typename T>
int static_vars_holder<T>::i1 = 100;
template<typename T>
double static_vars_holder<T>::d1 = 123.45;
template<typename T>
std::string static_vars_holder<T>::s1 = "test string";
template
struct static_vars_holder<void>;
}
typedef my_ns::miruna::static_vars_holder<void> static_vars;
namespace
{
int & i1 = static_vars::i1;
double & d1 = static_vars::d1;
std::string & s1 = static_vars::s1;
}
}
///////////////////////////////
#include <iostream>
using namespace std;
int main()
{
cout << my_ns::i1++ << endl;
cout << my_ns::d1++ << endl;
cout << my_ns::s1 << endl; my_ns::s1 += "...";
cout << my_ns::static_vars::i1 << endl;;
cout << my_ns::static_vars::d1 << endl;;
cout << my_ns::static_vars::s1 << endl;;
}
I2luY2x1ZGUgPHN0cmluZz4KCm5hbWVzcGFjZSBteV9ucwp7CgluYW1lc3BhY2UgbWlydW5hCgl7CgkJdGVtcGxhdGU8dHlwZW5hbWUgVD4KCQlzdHJ1Y3Qgc3RhdGljX3ZhcnNfaG9sZGVyCgkJewoJCQlzdGF0aWMgaW50IGkxOwoJCQlzdGF0aWMgZG91YmxlIGQxOwoJCQlzdGF0aWMgc3RkOjpzdHJpbmcgczE7CgkJfTsKCgkJdGVtcGxhdGU8dHlwZW5hbWUgVD4KCQlpbnQgc3RhdGljX3ZhcnNfaG9sZGVyPFQ+OjppMSA9IDEwMDsKCgkJdGVtcGxhdGU8dHlwZW5hbWUgVD4KCQlkb3VibGUgc3RhdGljX3ZhcnNfaG9sZGVyPFQ+OjpkMSA9IDEyMy40NTsKCgkJdGVtcGxhdGU8dHlwZW5hbWUgVD4KCQlzdGQ6OnN0cmluZyBzdGF0aWNfdmFyc19ob2xkZXI8VD46OnMxID0gInRlc3Qgc3RyaW5nIjsKCgkJdGVtcGxhdGUKCQlzdHJ1Y3Qgc3RhdGljX3ZhcnNfaG9sZGVyPHZvaWQ+OwoJfQoKCXR5cGVkZWYgbXlfbn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