[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-panel-devel
Subject:    Re: FYI: New calendar project (uses C++14 and C++17).
From:       Mark Gaiser <markg85 () gmail ! com>
Date:       2017-01-02 11:21:38
Message-ID: CAPd6JnGmHxmbA2O3jT=USEzDX=X1n-9WDLoRuyz2mvCruRKQ6w () mail ! gmail ! com
[Download RAW message or body]

On Mon, Jan 2, 2017 at 10:46 AM, Ivan Čukić <ivan.cukic@kde.org> wrote:

> Hi Mark,
>
> An alternative to Niebler's range-v3 and cppitertools you might want
> to try is boost.range (it is a part of the default boost package, I
> don't know whether it has everything you'd need for this).
>
> I haven't seen where you used struct-bindings - the code compiles fine
> with gcc -std=c++14.
>
> Cool you've started playing with things like these :)
>
> Cheers,
> Ivan
>

Hi Ivan,

You're right, i'm not using structured bindings anymore.
I didn't want to drop them, but i simplified my code before pushing it to
github ;)

Before my initial commit i had a vector of days for each month. While
iterating through months i also needed to know the number of days till that
point so i used a zip iterator like this

for (auto&& [daysThusFar, month] : iter::zip(...))
{

}

But i simplified that to use an algorithm for figuring out how many days
are in any given month and just increment a counter for the days thus far.
That made the zip redundant and with that the (only use of) structured
bindings as well.
Now it's just C++14 or perhaps even 11. My code looks 11, but the
iter::range or iter::chunked iterators might require it to be C++14.
Even then i play with "new" C++ features ;)

Btw, do take a look at the model [1] I've made if you like.
The model is derived from "QAbstractTableModel" which makes me a bit unsure
if it would work in QML. Since QML seems to have a requirement for it's
views to have the models be flat list models, not table models. But perhaps
it's working just fine these days. I don't know, haven't tried it.
The only thing the model misses is weeknumbers. Those can be calculated
with a single std::tm instance (which i have in updateModel(...)) but i
haven't implemented that yet.

Cheers,
Mark

[1]
https://github.com/markg85/cansole_calendar/blob/master/Qt/models/fixedmonthmodel.cpp

[Attachment #3 (text/html)]

<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jan 2, 2017 \
at 10:46 AM, Ivan Čukić <span dir="ltr">&lt;<a href="mailto:ivan.cukic@kde.org" \
target="_blank">ivan.cukic@kde.org</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex">Hi Mark,<br> <br>
An alternative to Niebler&#39;s range-v3 and cppitertools you might want<br>
to try is boost.range (it is a part of the default boost package, I<br>
don&#39;t know whether it has everything you&#39;d need for this).<br>
<br>
I haven&#39;t seen where you used struct-bindings - the code compiles fine<br>
with gcc -std=c++14.<br>
<br>
Cool you&#39;ve started playing with things like these :)<br>
<br>
Cheers,<br>
Ivan<br>
</blockquote></div><br></div><div class="gmail_extra">Hi Ivan,</div><div \
class="gmail_extra"><br></div><div class="gmail_extra">You&#39;re right, i&#39;m not \
using structured bindings anymore.</div><div class="gmail_extra">I didn&#39;t want to \
drop them, but i simplified my code before pushing it to github ;)</div><div \
class="gmail_extra"><br></div><div class="gmail_extra">Before my initial commit i had \
a vector of days for each month. While iterating through months i also needed to know \
the number of days till that point so i used a zip iterator like this</div><div \
class="gmail_extra"><br></div><div class="gmail_extra">for (auto&amp;&amp; \
[daysThusFar, month] : iter::zip(...))</div><div class="gmail_extra">{</div><div \
class="gmail_extra"><br></div><div class="gmail_extra">}</div><div \
class="gmail_extra"><br></div><div class="gmail_extra">But i simplified that to use \
an algorithm for figuring out how many days are in any given month and just increment \
a counter for the days thus far. That made the zip redundant and with that the (only \
use of) structured bindings as well.</div><div class="gmail_extra">Now it&#39;s just \
C++14 or perhaps even 11. My code looks 11, but the iter::range or iter::chunked \
iterators might require it to be C++14.<br></div><div class="gmail_extra">Even then i \
play with &quot;new&quot; C++ features ;)</div><div \
class="gmail_extra"><br></div><div class="gmail_extra">Btw, do take a look at the \
model [1] I&#39;ve made if you like.</div><div class="gmail_extra">The model is \
derived from &quot;QAbstractTableModel&quot; which makes me a bit unsure if it would \
work in QML. Since QML seems to have a requirement for it&#39;s views to have the \
models be flat list models, not table models. But perhaps it&#39;s working just fine \
these days. I don&#39;t know, haven&#39;t tried it.</div><div class="gmail_extra">The \
only thing the model misses is weeknumbers. Those can be calculated with a single \
std::tm instance (which i have in updateModel(...)) but i haven&#39;t implemented \
that yet.</div><div class="gmail_extra"><br></div><div \
class="gmail_extra">Cheers,</div><div class="gmail_extra">Mark</div><div \
class="gmail_extra"><br></div><div class="gmail_extra">[1]  <a \
href="https://github.com/markg85/cansole_calendar/blob/master/Qt/models/fixedmonthmode \
l.cpp">https://github.com/markg85/cansole_calendar/blob/master/Qt/models/fixedmonthmodel.cpp</a></div></div>




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic