mirror of
https://github.com/HowardHinnant/date.git
synced 2024-12-27 00:14:07 +08:00
Remove unneeded make_precision
This commit is contained in:
parent
09a19a09f4
commit
5a62c405e0
@ -3694,21 +3694,6 @@ struct static_pow10<0>
|
|||||||
static CONSTDATA std::uint64_t value = 1;
|
static CONSTDATA std::uint64_t value = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Rep, unsigned w, bool in_range = (w < 19)>
|
|
||||||
struct make_precision
|
|
||||||
{
|
|
||||||
using type = std::chrono::duration<Rep,
|
|
||||||
std::ratio<1, static_pow10<w>::value>>;
|
|
||||||
static CONSTDATA unsigned width = w;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class Rep, unsigned w>
|
|
||||||
struct make_precision<Rep, w, false>
|
|
||||||
{
|
|
||||||
using type = std::chrono::duration<Rep, std::micro>;
|
|
||||||
static CONSTDATA unsigned width = 6;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class Duration>
|
template <class Duration>
|
||||||
class decimal_format_seconds
|
class decimal_format_seconds
|
||||||
{
|
{
|
||||||
|
@ -20,16 +20,16 @@
|
|||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
|
|
||||||
// template <class Duration,
|
// template <class Duration>
|
||||||
// unsigned w = width<std::common_type<
|
|
||||||
// Duration,
|
|
||||||
// std::chrono::seconds>::type::period::den>::value>
|
|
||||||
// class decimal_format_seconds
|
// class decimal_format_seconds
|
||||||
// {
|
// {
|
||||||
|
// using CT = typename std::common_type<Duration, std::chrono::seconds>::type;
|
||||||
|
// using rep = typename CT::rep;
|
||||||
// public:
|
// public:
|
||||||
// using precision = typename make_precision<w>::type;
|
// static unsigned constexpr width = detail::width<CT::period::den>::value < 19 ?
|
||||||
// static auto constexpr width = make_precision<w>::width;
|
// detail::width<CT::period::den>::value : 6u;
|
||||||
//
|
// using precision = std::chrono::duration<rep,
|
||||||
|
// std::ratio<1, static_pow10<width>::value>>;
|
||||||
// private:
|
// private:
|
||||||
// std::chrono::seconds s_;
|
// std::chrono::seconds s_;
|
||||||
// precision sub_s_;
|
// precision sub_s_;
|
||||||
|
@ -1,63 +0,0 @@
|
|||||||
// The MIT License (MIT)
|
|
||||||
//
|
|
||||||
// Copyright (c) 2017 Howard Hinnant
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights
|
|
||||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
// SOFTWARE.
|
|
||||||
|
|
||||||
// template <unsigned w>
|
|
||||||
// struct make_precision
|
|
||||||
// {
|
|
||||||
// using type = std::chrono::duration<std::int64_t,
|
|
||||||
// std::ratio<1, static_pow10<w>::value>>;
|
|
||||||
// static constexpr unsigned width = w;
|
|
||||||
// };
|
|
||||||
|
|
||||||
#include "date.h"
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <type_traits>
|
|
||||||
|
|
||||||
int
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
using namespace date::detail;
|
|
||||||
using namespace std;
|
|
||||||
using namespace std::chrono;
|
|
||||||
|
|
||||||
static_assert(make_precision<int64_t, 0>::width == 0, "");
|
|
||||||
static_assert(is_same<make_precision<int64_t, 0>::type, duration<int64_t, ratio<1, 1>>>{}, "");
|
|
||||||
|
|
||||||
static_assert(make_precision<int64_t, 1>::width == 1, "");
|
|
||||||
static_assert(is_same<make_precision<int64_t, 1>::type, duration<int64_t, ratio<1, 10>>>{}, "");
|
|
||||||
|
|
||||||
static_assert(make_precision<int64_t, 2>::width == 2, "");
|
|
||||||
static_assert(is_same<make_precision<int64_t, 2>::type, duration<int64_t, ratio<1, 100>>>{}, "");
|
|
||||||
|
|
||||||
static_assert(make_precision<int64_t, 3>::width == 3, "");
|
|
||||||
static_assert(is_same<make_precision<int64_t, 3>::type, duration<int64_t, ratio<1, 1000>>>{}, "");
|
|
||||||
|
|
||||||
static_assert(make_precision<int64_t, 18>::width == 18, "");
|
|
||||||
static_assert(is_same<make_precision<int64_t, 18>::type, duration<int64_t, ratio<1, 1000000000000000000>>>{}, "");
|
|
||||||
|
|
||||||
static_assert(make_precision<int64_t, 19>::width == 6, "");
|
|
||||||
static_assert(is_same<make_precision<int64_t, 19>::type, microseconds>{}, "");
|
|
||||||
|
|
||||||
static_assert(make_precision<int64_t, 20>::width == 6, "");
|
|
||||||
static_assert(is_same<make_precision<int64_t, 20>::type, microseconds>{}, "");
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user