Move the new function to its own header.
This commit is contained in:
parent
91dca8810a
commit
b854a54293
3 changed files with 40 additions and 11 deletions
39
include/duckhandy/int_to_string_ary.hpp
Normal file
39
include/duckhandy/int_to_string_ary.hpp
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
/* Copyright 2017 Michele Santullo
|
||||||
|
* This file is part of "duckhandy".
|
||||||
|
*
|
||||||
|
* "duckhandy" is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* "duckhandy" is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with "duckhandy". If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef idB123739E9F8846899541DB26BEA86386
|
||||||
|
#define idB123739E9F8846899541DB26BEA86386
|
||||||
|
|
||||||
|
#include "lexical_cast.hpp"
|
||||||
|
|
||||||
|
namespace dhandy {
|
||||||
|
namespace customize {
|
||||||
|
template<typename C, std::size_t S>
|
||||||
|
struct array_to_t<C, S, MaxSizedArray<C, S>> {
|
||||||
|
static MaxSizedArray<C, S> make (MaxSizedArray<C, S>&& parIn) {
|
||||||
|
return parIn;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} //namespace customize
|
||||||
|
|
||||||
|
template <typename C, template <typename> class Tag=tags::dec, typename F=void>
|
||||||
|
inline auto int_to_string_ary (const F& parFrom) -> MaxSizedArray<C, Tag<F>::count_digits_bt(sprout::numeric_limits<F>::max())> {
|
||||||
|
return dhandy::lexical_cast<MaxSizedArray<C, Tag<F>::count_digits_bt(sprout::numeric_limits<F>::max())>, Tag, F>(parFrom);
|
||||||
|
}
|
||||||
|
} //namespace dhandy
|
||||||
|
|
||||||
|
#endif
|
|
@ -256,11 +256,6 @@ namespace dhandy {
|
||||||
return dhandy::implem::lexical_cast<Tag>::template convert<T, F>(parFrom);
|
return dhandy::implem::lexical_cast<Tag>::template convert<T, F>(parFrom);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename C, template <typename> class Tag=tags::dec, typename F=void>
|
|
||||||
inline auto int_to_string_ary (const F& parFrom) -> MaxSizedArray<C, Tag<F>::count_digits_bt(sprout::numeric_limits<F>::max())> {
|
|
||||||
return dhandy::lexical_cast<MaxSizedArray<C, Tag<F>::count_digits_bt(sprout::numeric_limits<F>::max())>, Tag, F>(parFrom);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace customize {
|
namespace customize {
|
||||||
template<>
|
template<>
|
||||||
struct index_to_char<char> {
|
struct index_to_char<char> {
|
||||||
|
@ -304,12 +299,6 @@ namespace dhandy {
|
||||||
return std::string(parIn.begin(), parIn.end());
|
return std::string(parIn.begin(), parIn.end());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
template<typename C, std::size_t S>
|
|
||||||
struct array_to_t<C, S, MaxSizedArray<C, S>> {
|
|
||||||
static MaxSizedArray<C, S> make (MaxSizedArray<C, S>&& parIn) {
|
|
||||||
return parIn;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} //namespace customize
|
} //namespace customize
|
||||||
} //namespace dhandy
|
} //namespace dhandy
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include "catch.hpp"
|
#include "catch.hpp"
|
||||||
#include "duckhandy/lexical_cast.hpp"
|
#include "duckhandy/lexical_cast.hpp"
|
||||||
|
#include "duckhandy/int_to_string_ary.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
Loading…
Reference in a new issue