[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] Cating doubles to enums
From: |
Vadim Zeitlin |
Subject: |
Re: [lmi] Cating doubles to enums |
Date: |
Tue, 6 Nov 2018 01:59:40 +0100 |
On Tue, 6 Nov 2018 00:36:17 +0000 Greg Chicares <address@hidden> wrote:
GC> For now, I've tried to cover all the floating-to-enum conversions
GC> so that an msvc build will work again. Let me commit that now and
GC> ask you to make sure that goal has been achieved.
I can confirm that everything compiles fine with MSVS 2017 now, thank
you!
GC> Most of the changes are clearly for the better IMO, but this one
GC> bothers me:
GC>
GC> - oenum_alb_or_anb const alb_anb =
GC> - static_cast<oenum_alb_or_anb>
GC> - (database_->Query(DB_AgeLastOrNearest)
GC> - );
GC> + oenum_alb_or_anb alb_anb;
GC> + database_->query_into(alb_anb, DB_AgeLastOrNearest);
GC>
GC> because there's no 'alb_anb' data member to assign into;
Sorry but why is this a problem? I.e. why should query_into() be only used
with members and not local variables?
GC> maybe
GC> that suggests that such a member should exist, or maybe it means
GC> I should reverse the order of the function template arguments
GC> and default the "destination" argument:
GC>
GC> template<typename T>
GC> -void product_database::query_into(T& dst, e_database_key k) const
GC> +T product_database::query_into(e_database_key k, T& dst = T(0)) const
This won't compile, will it? A non-const reference can't be bound to a
temporary.
GC> to allow some syntax like
GC>
GC> - oenum_alb_or_anb alb_anb;
GC> - database_->query_into(alb_anb, DB_AgeLastOrNearest);
GC> + auto const alb_anb =
{database_->query_into<oenum_alb_or_anb>(DB_AgeLastOrNearest)};
It looks like you're really looking for what had been suggested before,
i.e.
template<typename T>
T product_database::query_into(e_database_key k) const;
which could then be used as
auto const alb_anb = query_into<oenum_alb_or_anb>(DB_AgeLastOrNearest);
Or am I missing something?
VZ
- [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, 2018/11/05
- 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 <=
- Re: [lmi] Cating doubles to enums, Greg Chicares, 2018/11/06
- Re: [lmi] Cating doubles to enums, Greg Chicares, 2018/11/06