Expand tuple values as callable arguments


On Tue, Jun 9, 2009 at 9:00 AM, Dominique Devienne
Given a boost::tuple abc; is there a boost facility that allows to "expand" abc into its a, b, c values to pass to a callable (actual function T f(A,B,C), boost::function
, fusion callables, etc...)? If so, would implicit conversions allowed and performed during a real call also happen using that facility?
And if the "callable" is a constructor, is there a way to call a constructor? Thanks, --DD
PS: Our app is plugin based and heavily uses factories in the base framework, but these are polymorphic and thus void* based in the base abstract factory class, and relied on default construction only. I've introduced non-default construction, and additional type safety, but it's still clunky and I'm exploring ways to provide a fully type safe plugeable factory mechanism, with static-based dynamic-registration on shared lib loading (when plugins are loaded), the ability to construct name-registered types with arbitrary args. A base type must support creation by more than one factory, taking different args (but a particular concrete type may choose to support only a subset of the factories its base type supports.) Any factory lib out there you know that fits the above description?
I have done that exact thing a year or so back using Boost.Fusion. Cannot check how I did it off-hand, but I think it was the invoke thing, along with a few recursive templates to build what it needs...

Dominique Devienne wrote:
Given a boost::tuple abc; is there a boost facility that allows to "expand" abc into its a, b, c values to pass to a callable (actual function T f(A,B,C), boost::function
, fusion callables, etc...)? If so, would implicit conversions allowed and performed during a real call also happen using that facility?
And if the "callable" is a constructor, is there a way to call a constructor? Thanks, --DD
PS: Our app is plugin based and heavily uses factories in the base framework, but these are polymorphic and thus void* based in the base abstract factory class, and relied on default construction only. I've introduced non-default construction, and additional type safety, but it's still clunky and I'm exploring ways to provide a fully type safe plugeable factory mechanism, with static-based dynamic-registration on shared lib loading (when plugins are loaded), the ability to construct name-registered types with arbitrary args. A base type must support creation by more than one factory, taking different args (but a particular concrete type may choose to support only a subset of the factories its base type supports.) Any factory lib out there you know that fits the above description?
Fusion Functional (see http://tinyurl.com/oodztm) does that, but it seems you know already. Boost.Tuple is a valid fusion sequence, so you can use it for your fusion fused and unfused forms. Regards, -- Joel de Guzman http://www.boostpro.com http://spirit.sf.net

On Tue, Jun 9, 2009 at 10:32 AM, Joel de
Guzman
Dominique Devienne wrote:
Given a boost::tuple abc; is there a boost facility that allows to "expand" abc into its a, b, c values to pass to a callable
Fusion Functional (see http://tinyurl.com/oodztm) does that, but it seems you know already. Boost.Tuple is a valid fusion sequence, so you can use it for your fusion fused and unfused forms.
Thanks. I read too fast that section of the Fusion doc, and missed what I was looking for. Yes, I was aware that Fusion has Callables, but trying to figure out what from Bind, FunctionTypes, Function, BLL, or Fusion applied to what I'm trying to achieve, I'm a bit confused by the choices. I'm finding it non trivial to go from reading the doc of Fusion or BLL and be able to conceptualize how and when to use them, or not use them. I can't say I've read all the doc yet, but I for one would appreciate a bit more hand holding and examples to better grasp some concepts. Easier said that done, I know, and I sure am thankful for the high quality code shared with the C++ community. The failure is mine to understand the boost libs faster / better ;-) I'll see what I can figure out and will try to provide more concrete sample code if I get stuck. Thanks, --DD PS: Any Effective Meta-Programming or Fusion book or resource out there or in the works? The Template Meta-Programming book focused more on implementing MPL-like containers and algos that appropriately and effectively using libraries like MPL or Fusion for someone like me.
participants (3)
-
Dominique Devienne
-
Joel de Guzman
-
OvermindDL1