add counter

This commit is contained in:
chatlanin 2022-09-15 09:47:15 +03:00
parent cb55987746
commit 9f47c86bc2
2 changed files with 18 additions and 0 deletions

View File

@ -41,6 +41,13 @@ struct ForTypeTrace
int a;
};
struct counter_test : public hack::utils::counter<int>
{
counter_test() : id { ++hack::utils::counter<int>::id } { }
int id;
};
int main(int argc, char *argv[])
{
{// ex: string::split_str
@ -218,4 +225,9 @@ int main(int argc, char *argv[])
hack::log()(hack::security::is_string<decltype ('c')>::value);
hack::log()(hack::security::is_string<decltype ("c")>::value);
}
{
counter_test a, b, c;
hack::log()(c.id);
}
}

View File

@ -62,4 +62,10 @@ namespace hack::utils
return result;
}
template<typename T, T value = 0>
struct counter
{
inline static T id = value;
};
}