-template <typename varT>
-inline
-const std::string & x2str(varT x, std::string & s)
-{
- varT xx = x;
- int pos = 1;
-
- x /= 10;
- while (x != 0)
- {
- x /= 10;
- pos++;
- }
-
- if (xx < 0)
- {
- pos++;
- s.resize(pos, 0);
- s[0] = '-';
- }
- else if (xx > 0)
- {
- s.resize(pos, 0);
- }
- else
- {
- s.resize(1, 0);
- s[0] = '0';
- return s;
- }
-
- x = xx;
-
- while (x != 0)
- {
- if (x < 0)
- s[--pos] = -(x % 10) + '0';
- else
- s[--pos] = x % 10 + '0';
-
- x /= 10;
- }
-
- return s;
-}
-//-----------------------------------------------------------------------------
-template <typename varT>
-inline
-const std::string & unsigned2str(varT x, std::string & s)
-{
- varT xx = x;
- int pos = 1;
-
- x /= 10;
- while (x != 0)
- {
- x /= 10;
- pos++;
- }
-
- if (xx > 0)
- {
- s.resize(pos, 0);
- }
- else
- {
- s.resize(1, 0);
- s[0] = '0';
- return s;
- }
-
- x = xx;
-
- while (x != 0)
- {
- s[--pos] = x % 10 + '0';
-
- x /= 10;
- }
-
- return s;
-}
-//-----------------------------------------------------------------------------