|
Boost : |
Subject: Re: [boost] New library proposal: Autodiff
From: Peter Dimov (lists_at_[hidden])
Date: 2018-12-20 19:48:48
Matt Pulver wrote:
> For example, the following will not compile with pre-17 compilers if
> `constexpr` is dropped:
>
> template<typename RealType,size_t Order>
> constexpr size_t dimension<RealType,Order>::depth()
> {
> if constexpr (is_dimension<RealType>::value)
> return 1 + RealType::depth();
> else
> return 1;
> }
This specific case isn't hard to support either, although whether you would
want to invest the effort is up to you.
template<typename RealType,size_t Order>
constexpr size_t dimension<RealType,Order>::depth()
{
return dimension<RealType,Order>::depth_impl(
is_dimension<RealType>() );
}
template<typename RealType,size_t Order>
constexpr size_t dimension<RealType,Order>::depth_impl( true_type )
{
return 1 + RealType::depth();
}
template<typename RealType,size_t Order>
constexpr size_t dimension<RealType,Order>::depth_impl( false_type )
{
return 1;
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk