Comments on: Templates as first-class citizens in C++11 http://vitiy.info/templates-as-first-class-citizens-in-cpp11/ Programming, architecture and design (ะก++, QT, .Net/WPF, Android, iOS, NoSQL, distributed systems, mobile development, image processing, etc...) Tue, 26 Jul 2016 03:34:00 +0000 hourly 1 https://wordpress.org/?v=5.4.2 By: qicosmos http://vitiy.info/templates-as-first-class-citizens-in-cpp11/#comment-45961 Tue, 26 Jul 2016 03:34:00 +0000 http://vitiy.info/?p=524#comment-45961 call_impl can be resolved by std::index_sequence, here is the code:
template
auto call_impl(Arg&& arg, const std::index_sequence&) const ->decltype(std::get(functions_)(std::forward(arg)))
{
return std::get
(functions_)(std::forward(arg));
}

template
auto call_impl(Arg&& arg, const std::index_sequence
&) const ->decltype(call_impl(std::get(functions_)(std::forward(arg)), std::index_sequence{}))
{
return call_impl(std::get
(functions_)(std::forward(arg)), std::index_sequence{});
}

template
auto call(Arg&& arg) const-> decltype(call_impl(std::forward(arg), std::make_index_sequence{}))
{
return call_impl(std::forward(arg), std::make_index_sequence{});
}

]]>
By: qicosmos http://vitiy.info/templates-as-first-class-citizens-in-cpp11/#comment-45960 Tue, 12 Jul 2016 07:33:00 +0000 http://vitiy.info/?p=524#comment-45960 Hi, Victor, can you improve the code with c++14, now vs2015 and gcc6.0 are surpport most c++11 features. I think c++14 will make the code clean and simple.

]]>
By: Victor Laskin http://vitiy.info/templates-as-first-class-citizens-in-cpp11/#comment-45949 Tue, 12 Jan 2016 07:28:00 +0000 http://vitiy.info/?p=524#comment-45949 Thanks. No problem with that – you could use code as you like. As for the video – it will be available soon (I expect it to be at jan or feb).

]]>
By: Goobley http://vitiy.info/templates-as-first-class-citizens-in-cpp11/#comment-45948 Mon, 11 Jan 2016 23:21:00 +0000 http://vitiy.info/?p=524#comment-45948 Hey, great job with this, I’ve based some code on some of this, in the process of becoming a small header-only library. Any chance you could officially state it being under a certain license so I can properly credit it. (I’d rather anything non-GPL). I found your talk via your MeetingCPP 2015 slides, any chance there’ll be a video of the talk that goes with them? Cheers!

]]>
By: Victor Laskin http://vitiy.info/templates-as-first-class-citizens-in-cpp11/#comment-45900 Wed, 29 Apr 2015 16:08:00 +0000 http://vitiy.info/?p=524#comment-45900 Hello, yes, it’s less natural – but you can switch it with some other syntax you prefere. The main idea was to show that such decomposition is possible.

]]>
By: qicosmos http://vitiy.info/templates-as-first-class-citizens-in-cpp11/#comment-45899 Wed, 29 Apr 2015 03:30:00 +0000 http://vitiy.info/?p=524#comment-45899 Hi Victor, i don’t think “<<" is a good choice, it's not natural, your old post "functional piping" is better.

]]>
By: Victor Laskin http://vitiy.info/templates-as-first-class-citizens-in-cpp11/#comment-45890 Sun, 08 Mar 2015 10:35:00 +0000 http://vitiy.info/?p=524#comment-45890 Yes, thanks. Sure, it’s obvious typo during manual macro expansion. ps. I can’t wait for C++14 where result types could be written as decltype(auto) and whole code will be a lot shorter.

]]>
By: Dan George http://vitiy.info/templates-as-first-class-citizens-in-cpp11/#comment-45889 Sun, 08 Mar 2015 04:46:00 +0000 http://vitiy.info/?p=524#comment-45889 Hi Victor, thanks for another inspiring post. I think there is a typo in the tfn_print wrapper: dectype(X( s/b dectype(print(, right?

]]>
By: Victor Laskin http://vitiy.info/templates-as-first-class-citizens-in-cpp11/#comment-45888 Sat, 07 Mar 2015 21:49:00 +0000 http://vitiy.info/?p=524#comment-45888 Anton, Thanks. No, just && was missing there. I fixed it.

]]>
By: AntonBikineev http://vitiy.info/templates-as-first-class-citizens-in-cpp11/#comment-45887 Sat, 07 Mar 2015 20:47:00 +0000 http://vitiy.info/?p=524#comment-45887 I just read your first code snippet and got a question. Is there any sense to use std forward for non universal references?

]]>
By: Victor Laskin http://vitiy.info/templates-as-first-class-citizens-in-cpp11/#comment-45886 Thu, 05 Mar 2015 18:36:00 +0000 http://vitiy.info/?p=524#comment-45886 Hello, thanks for comment. No, it’s not just academic – you can easily compile gist from link at the end of post. It may be more problematic to get your developers think in more functional way, but starting to use the technic is easy.
As this is quite new approach I can’t provide any information about long term maintainability (A lot of people still can’t use even c++11 in production).

]]>