Comments for Victor Laskin's Blog http://vitiy.info Programming, architecture and design (С++, QT, .Net/WPF, Android, iOS, NoSQL, distributed systems, mobile development, image processing, etc...) Thu, 09 May 2019 11:14:00 +0000 hourly 1 https://wordpress.org/?v=5.4.2 Comment on C++14: Transducers by bacoo zhao http://vitiy.info/cpp14-how-to-implement-transducers/#comment-46052 Thu, 09 May 2019 11:14:00 +0000 http://vitiy.info/?p=621#comment-46052 This is a code that could compiles & runs.

]]>
Comment on C++14: Transducers by bacoo zhao http://vitiy.info/cpp14-how-to-implement-transducers/#comment-46051 Thu, 09 May 2019 11:13:00 +0000 http://vitiy.info/?p=621#comment-46051 https://github.com/bacoo/code_lake/blob/master/transducer/transducer.cpp

]]>
Comment on How to make simple CQRS implementation without Event Sourcing by Johan t Hart http://vitiy.info/how-to-make-simple-cqrs-implementation-without-event-sourcing/#comment-46046 Tue, 15 Jan 2019 11:15:00 +0000 http://vitiy.info/?p=347#comment-46046

as you have to keep not only all events inside your eventstore, but also all past event handlers to replay them

No I think thats wrong. Old versions of events should be replayable with new event handlers. For new data in the events there should be defaults. If the old event is not up-castable, then (as a rule of thumb), it is not the same event but a new event type.

]]>
Comment on C++11 functional decomposition – easy way to do AOP by Johnny Serup http://vitiy.info/c11-functional-decomposition-easy-way-to-do-aop/#comment-45981 Tue, 01 May 2018 11:26:00 +0000 http://vitiy.info/?p=461#comment-45981 I think it is because it is in C99 (compound literals) syntax – try instead this:

template
void for_each_argument(F f, Args&&… args) {
using arrT = int[];
static_cast(arrT{ (f(std::forward(args)), 0)… });
}

]]>
Comment on How to create parallax effect using accelerometer by Colin Kiama http://vitiy.info/how-to-create-parallax-effect-using-accelerometer/#comment-45977 Thu, 08 Mar 2018 01:52:00 +0000 http://vitiy.info/?p=137#comment-45977 Thank you for sharing this. I’ve got something working for Windows 10.

]]>
Comment on C++11 functional decomposition – easy way to do AOP by Kapil Dhaimade http://vitiy.info/c11-functional-decomposition-easy-way-to-do-aop/#comment-45976 Tue, 06 Mar 2018 11:54:00 +0000 http://vitiy.info/?p=461#comment-45976 Hi. It’s a great article! I’m interested in applying this to some of our code.

How should we factorize non-static methods of a class? If it were usersManager.findUser(), would the final call always be a global function like findUserFinal() which wraps instance of UserManager?

Also, wrapping all these functions should be done during app initialization in wiring up stage and there should be some service/factory to provide all factorized functions? Otherwise, the code would become polluted with all the repeated wrapping calls, right?

]]>
Comment on Named tuple for C++ by fish2000 http://vitiy.info/named-tuple-for-cplusplus/#comment-45974 Mon, 11 Sep 2017 22:56:00 +0000 http://vitiy.info/?p=638#comment-45974 I loved this idea – but I found it hard to use beyond the toy example the blog entry furnishes. This was because if you try to return a named tuple, you have to have a consistent return type; I used some simple macros to declare a named tuple type to use in this way:

#define SLOT_TYPE(__str__, __type__) param(__str__) = std::remove_reference_t{}

#define DECLARE_NAMED_TUPLE(…) decltype(namedtup::make_named_tuple(__VA_ARGS__))

… right? but then if you are using a tuple in a return statement like:

return make_named_tuple(param(“yodogg”) = 42);

… that yields a different type than, say:

int integer = 42;
return make_named_tuple(param(“yodogg”) = integer);

… the named parameter in first example, with the literal integer, has type int whereas the second example (in which the param value is stored in a variable) has type int &.

This makes the named tuple idiom, as implemented here, much less useful. I have tried to monkey around with this code, in order to deal with references in the manner I’ve described here, but it seems non-trivial to implement (especially in the case of struct types, where pass-by-reference is desirable). If there’s a solution to this, I’d be interested in seeing what it is, as I still like the named tuple idea. Yes!

]]>
Comment on How to create parallax effect using accelerometer by Roberto http://vitiy.info/how-to-create-parallax-effect-using-accelerometer/#comment-45973 Sun, 27 Aug 2017 04:33:00 +0000 http://vitiy.info/?p=137#comment-45973 Hello, first of all, thank you for sharing this! I’m sorry if this post it’s too old but I’m implementing this and it’s working fine but I need some help. I’m moving a background with this effect but I want it to have a limit, for example, I want that from its original position it only moves a maximum of x -20/+20, y -20/+20

I’m trying to limit this but I only get a mess with every thing I try. Can you help me please?

]]>
Comment on C++11 functional decomposition – easy way to do AOP by Joe Cool http://vitiy.info/c11-functional-decomposition-easy-way-to-do-aop/#comment-45972 Fri, 18 Aug 2017 00:54:00 +0000 http://vitiy.info/?p=461#comment-45972 Hi, great article!

I am new to C++ and have a problem compiling your example with Visual Studio 2017. The for_each_argument function (see below) creates an compiler error: C4576 ‘a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax’.

Any idea how to fix this?

Thanks for your help!
Joe

template
void for_each_argument ( F f, Args&&… args )
{
(void)(int[]) {(f(forward(args)) , 0)…};
}

]]>
Comment on Functional pipeline in C++11 by Victor Laskin http://vitiy.info/functional-pipeline-in-c11/#comment-45970 Fri, 21 Jul 2017 18:45:00 +0000 http://vitiy.info/?p=435#comment-45970 Yes, you can.

]]>
Comment on Functional pipeline in C++11 by Piers Powlesland http://vitiy.info/functional-pipeline-in-c11/#comment-45969 Wed, 19 Jul 2017 08:55:00 +0000 http://vitiy.info/?p=435#comment-45969 Hi Victor, I’m a bit of a noob when it comes to c++ so apologies if this is a really stupid question.

With this approach can you chain together functions with different input and output types. For example (int,string) | (string,bool) | (bool, void)

]]>