raskolnikov
2016-04-08 01:56:51 UTC
{ edited by mod to shorten lines to ~70 characters. -mod }
Hi!
I was thinking about what some people including I are trying with
transducers in C++14, which involves defining global lambdas [1] [2].
However, I am becoming afraid that this in fact violates the One
Definition Rule. Not only is the object defined in multiple translation
units, it is even defined with different types!
I'd imagine that one workaround would be to wrap the the lambda in
a factory
function template.
template <typename T=int>
auto lambdaz() { return [] { ... } };
And use like lambdaz(). This would work for most transducers since the
outermost lambda layer can be turned into a normal function with minor
implications for clients.
Another option would be to use a variable template, something
like:
template <typename T=int>
auto lambdaz = [] { ... };
But then use would require to type lambdaz<> with those weird angles
that make no sense for the client.
Any ideas on how can this be solved simpler?
Thanks!
JP
[1]
https://github.com/Ableton/atria/blob/master/src/atria/xform/transducer/
map.hpp
[2]
https://github.com/kirkshoop/transducer/blob/master/src/ducer/ducer_mapp
er.h
Hi!
I was thinking about what some people including I are trying with
transducers in C++14, which involves defining global lambdas [1] [2].
However, I am becoming afraid that this in fact violates the One
Definition Rule. Not only is the object defined in multiple translation
units, it is even defined with different types!
I'd imagine that one workaround would be to wrap the the lambda in
a factory
function template.
template <typename T=int>
auto lambdaz() { return [] { ... } };
And use like lambdaz(). This would work for most transducers since the
outermost lambda layer can be turned into a normal function with minor
implications for clients.
Another option would be to use a variable template, something
like:
template <typename T=int>
auto lambdaz = [] { ... };
But then use would require to type lambdaz<> with those weird angles
that make no sense for the client.
Any ideas on how can this be solved simpler?
Thanks!
JP
[1]
https://github.com/Ableton/atria/blob/master/src/atria/xform/transducer/
map.hpp
[2]
https://github.com/kirkshoop/transducer/blob/master/src/ducer/ducer_mapp
er.h
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]