Comments on: C++11 functional decomposition – easy way to do AOP http://vitiy.info/c11-functional-decomposition-easy-way-to-do-aop/ Programming, architecture and design (С++, QT, .Net/WPF, Android, iOS, NoSQL, distributed systems, mobile development, image processing, etc...) Tue, 01 May 2018 11:26:00 +0000 hourly 1 https://wordpress.org/?v=5.4.2 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)… });
}

]]>
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?

]]>
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)…};
}

]]>
By: Aspekt- und Objektorientiertes C++ - Felix' Blog - Felix' Blog http://vitiy.info/c11-functional-decomposition-easy-way-to-do-aop/#comment-45932 Thu, 27 Aug 2015 12:43:06 +0000 http://vitiy.info/?p=461#comment-45932 […] vorhabe, ich kann’s mit C++ verwirklichen. Die ideale Kombination habe ich aber auf dieser Seite  (ebenfalls auf Englisch) entdeckt. Dort wird die Kombination aus Aspekt-Orientierter und aus […]

]]>
By: Victor Laskin http://vitiy.info/c11-functional-decomposition-easy-way-to-do-aop/#comment-45865 Tue, 10 Feb 2015 16:11:00 +0000 http://vitiy.info/?p=461#comment-45865 Hmm, thanks. I fixed missing apostrophes in text. Sorry 🙂

]]>
By: Martin Moene http://vitiy.info/c11-functional-decomposition-easy-way-to-do-aop/#comment-45864 Tue, 10 Feb 2015 15:53:00 +0000 http://vitiy.info/?p=461#comment-45864 Nice article!

On a different aspect 😉
– property of it: its property
– it is: it’s
– let us: let’s

]]>
By: fj http://vitiy.info/c11-functional-decomposition-easy-way-to-do-aop/#comment-45858 Fri, 06 Feb 2015 21:09:00 +0000 http://vitiy.info/?p=461#comment-45858 That’s true. Just trying to do similar stuff in C++03 with all those hand written function objects and lack of decltype might be a nightmare of hundreds of lines of highly templated code! I am very glad we have C++11-enabled compilers available today, and, hopefully, one day I will be allowed to use C++11 in the production code…

]]>
By: Victor Laskin http://vitiy.info/c11-functional-decomposition-easy-way-to-do-aop/#comment-45857 Fri, 06 Feb 2015 21:01:00 +0000 http://vitiy.info/?p=461#comment-45857 Actually, its relatively low amount of -ish code for such task in cpp, but of cause, in haskell such composition is much more terse.

]]>
By: fj http://vitiy.info/c11-functional-decomposition-easy-way-to-do-aop/#comment-45856 Fri, 06 Feb 2015 19:48:00 +0000 http://vitiy.info/?p=461#comment-45856 That looks like ordinary programming with Monads (and Applicative in for_each_argument) in Haskell. But here we have C++ with tons of -ish code instead 🙂

]]>
By: Victor Laskin http://vitiy.info/c11-functional-decomposition-easy-way-to-do-aop/#comment-45850 Thu, 05 Feb 2015 21:03:00 +0000 http://vitiy.info/?p=461#comment-45850 Thanks, you are right, its working without cast. I will change in text accordingly.

]]>
By: Scott Prager http://vitiy.info/c11-functional-decomposition-easy-way-to-do-aop/#comment-45849 Thu, 05 Feb 2015 20:52:00 +0000 http://vitiy.info/?p=461#comment-45849 Hi, in to_function, “static_cast<typename function_traits::function>(lambda);” should really just be “typename function_traits::function(lambda);”. A static cast adds no real safety here.

]]>