[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] Cating doubles to enums
From: |
Greg Chicares |
Subject: |
Re: [lmi] Cating doubles to enums |
Date: |
Mon, 5 Nov 2018 22:31:57 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 |
On 2018-11-04 20:36, Vadim Zeitlin wrote:
> On Sun, 4 Nov 2018 17:49:17 +0000 Greg Chicares <address@hidden> wrote:
>
> GC> Therefore, what do you think of, say,
> GC> double query (database_key);
> GC> void query_ref(T&, database_key);
> GC> void query_ref(vector<T>&, database_key);
> GC> which distinguishes the names without denying the similarity of
> GC> the operations?
>
> I'm fine with this.
>
> GC> I tried different second lexemes:
> GC> query_value meaningless--they all retrieve values
> GC> query_into seems obscure
>
> But my preferred version would be this one.
Then its name shall be called query_into<>(), and the implementation
for scalars is:
template<typename T>
void product_database::query_into(T& dst, e_database_key k) const
{
double d = [result of calling a more fundamental overload]
if constexpr(std::is_enum_v<T>)
{
dst = static_cast<T>(bourn_cast<std::underlying_type_t<T>>(d));
}
else
{
static_assert(std::is_integral_v<T>);
dst = bourn_cast<T>(d);
}
}
which falls just short of my threshold for adding a unit test module.
- [lmi] Cating doubles to enums, Vadim Zeitlin, 2018/11/02
- Re: [lmi] Cating doubles to enums, Greg Chicares, 2018/11/02
- Re: [lmi] Cating doubles to enums, Vadim Zeitlin, 2018/11/02
- Re: [lmi] Cating doubles to enums, Greg Chicares, 2018/11/04
- Re: [lmi] Cating doubles to enums, Vadim Zeitlin, 2018/11/04
- Re: [lmi] Cating doubles to enums,
Greg Chicares <=
- Re: [lmi] Cating doubles to enums, Vadim Zeitlin, 2018/11/05
- Re: [lmi] Cating doubles to enums, Greg Chicares, 2018/11/05
- Re: [lmi] Cating doubles to enums, Vadim Zeitlin, 2018/11/05
- Re: [lmi] Cating doubles to enums, Greg Chicares, 2018/11/06
- Re: [lmi] Cating doubles to enums, Greg Chicares, 2018/11/06