[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] [lmi-commits] master 6335e9a 1/4: Render comprehensible
From: |
Vadim Zeitlin |
Subject: |
Re: [lmi] [lmi-commits] master 6335e9a 1/4: Render comprehensible |
Date: |
Thu, 26 Jan 2017 02:27:55 +0100 |
On Thu, 26 Jan 2017 01:17:21 +0000 (UTC) Greg Chicares <address@hidden> wrote:
GC> branch: master
GC> commit 6335e9afadf5c5a4e6e9e98521a9653f2a9c67fe
GC> Author: Gregory W. Chicares <address@hidden>
GC> Commit: Gregory W. Chicares <address@hidden>
GC>
GC> Render comprehensible
I'm not sure if you find C++11 vararg templates comprehensible...
GC> +// One check[0-9]() function for each number of ctor arguments.
GC> +
GC> +template<typename T>
GC> +void check0
GC> + (T const* d
GC> + ,int n
GC> + ,std::string const& e
GC> + ,char const* file
GC> + ,int line
GC> + )
GC> +{
GC> + InputSequence seq(e, n, 90, 95, 0, 2002, 0);
GC> + std::vector<double> v(seq.linear_number_representation());
GC> + bool b = std::equal(d, d + n, v.begin());
GC> + if(!b) check(d, n, e);
GC> + INVOKE_BOOST_TEST(b, file, line);
GC> +}
GC> +
GC> +template<typename T>
GC> +void check1
GC> + (T const* d
GC> + ,int n
GC> + ,std::string const& e
GC> + ,std::vector<std::string> const& k
GC> + ,char const* const* c
GC> + ,char const* file
GC> + ,int line
GC> + )
GC> +{
GC> + InputSequence seq(e, n, 90, 95, 0, 2002, 0, k);
GC> + std::vector<double> v(seq.linear_number_representation());
GC> + std::vector<std::string> s(seq.linear_keyword_representation());
GC> + bool b =
GC> + std::equal(d, d + n, v.begin())
GC> + && std::equal(c, c + n, s.begin())
GC> + ;
GC> + if(!b) check(d, n, e, k, c);
GC> + INVOKE_BOOST_TEST(b, file, line);
GC> +}
GC> +
GC> +template<typename T>
GC> +void check2
GC> + (T const* d
GC> + ,int n
GC> + ,std::string const& e
GC> + ,std::vector<std::string> const& k
GC> + ,char const* const* c
GC> + ,std::string const& w
GC> + ,char const* file
GC> + ,int line
GC> + )
GC> +{
GC> + InputSequence seq(e, n, 90, 95, 0, 2002, 0, k, w);
GC> + std::vector<double> v(seq.linear_number_representation());
GC> + std::vector<std::string> s(seq.linear_keyword_representation());
GC> + bool b =
GC> + std::equal(d, d + n, v.begin())
GC> + && std::equal(c, c + n, s.begin())
GC> + ;
GC> + if(!b) check(d, n, e, k, c, w);
GC> + INVOKE_BOOST_TEST(b, file, line);
GC> +}
... but the functions check1() and check2() could clearly be combined into
a single function using them, which would, IMHO, be nicer because these not
completely trivial functions seem to be identical otherwise.
I'm not sure if check0() could be _easily_ folded into the same vararg
template however, at least with C++11 (with C++17 and its fold expressions
it would be trivial).
Regards,
VZ
- Re: [lmi] [lmi-commits] master 6335e9a 1/4: Render comprehensible,
Vadim Zeitlin <=