Skip to content

Use strongly typed configuration options instead of multiple bools #45

Open
@jk-jeon

Description

@jk-jeon

@Naios Here are some suggestions about fu2::function_base.

  1. There are too many boolean template parameters. It's hard to imagine what specific combination of policies are given if we just write
template<typename Arg>
using my_consumer = fu2::function_base<true, false, fu2::capacity_fixed<100U>,
                                       true, false, void(Arg)&&>;

In my opinion, better alternatives might be:

  • Use separate enum types for each policy parameter, or
  • Change policy parameters from non-type parameters to type parameters, and define new empty type for each policy.

The second approach might require more template metaprogramming, but it's open-ended (users can add more options at their will) while the enum approach is closed-ended. This might be either pros or cons, though.

I recommend the enum approach, and I think there is virtually no downside of it compared to the boolean approach, except that the implementation might be a bit more verbose.

  1. This one is about README. I'm not sure what HasStrongExceptGuarantee is meant to mean. I mean, I know what strong exception guarantee means in general, but I think it might be better to explicitly say (1) where are the places fu2::function_base is guarding against exceptions when HasStrongExceptGuarantee is set to be true, and (2) exactly what invariants are preserved. I assumed these are about copy assignment, is that correct?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions