Skip to content

Variadic and_/or_ [Feature Request] #251

@Alexhuszagh

Description

@Alexhuszagh

While porting boost::mpl code to Brigand, I noticed that although and_ and or_ exist, they only support 2 arguments.

It's fairly easy to versions taking a variadic parameter pack, using template specialization, without adding much code bloat.

And

  template<typename... Ts>
  struct and_;

  template<>
  struct and_<>: true_type {};

  template<typename T, typename... Ts>
  struct and_<T, Ts...> : brigand::integral_constant < typename T::value_type, T::value && and_<Ts...>::value > {};

Or

  template<typename... Ts>
  struct or_;

  template<>
  struct or_<> : brigand::integral_constant < bool, false > {};

  template <typename T, typename... Ts>
  struct or_<T, Ts...> : brigand::integral_constant < typename T::value_type, T::value || or_<Ts...>::value > {};

If there's any interest, I can make a pull request. Thanks for the excellent library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions