Skip to content

[Feature request] make wrappers #44

@denzor200

Description

@denzor200

Inspired by std::make_tuple for std::tuple..
I recently tried to create 4 simple make methods for types from this library:

template<typename T, typename M>
ordered_unique<T, M> make_ordered_unique(T, M)
{
    return {};
}
 
template<typename T, typename M>
ordered_non_unique<T, M> make_ordered_non_unique(T, M)
{
    return {};
}
 
template<typename... T>
indexed_by<T...> make_indexed_by(T...)
{
    return {};
}
 
template<typename T, typename I>
multi_index_container<T, I> make_multi_index_container(I)
{
    return {};
}

These methods allow me to write like this:

auto es = make_multi_index_container<employee>(make_indexed_by(
        make_ordered_unique(     tag<id>{},  BOOST_MULTI_INDEX_MEMBER(employee,int,id){}),
        make_ordered_non_unique( tag<name>{},BOOST_MULTI_INDEX_MEMBER(employee,std::string,name){}), 
        make_ordered_non_unique( tag<age>{}, BOOST_MULTI_INDEX_MEMBER(employee,int,age){})));

..And the same code without methods (how it works now):

typedef multi_index_container<
  employee,
  indexed_by<
    ordered_unique<
      tag<id>,  BOOST_MULTI_INDEX_MEMBER(employee,int,id)>,
    ordered_non_unique<
      tag<name>,BOOST_MULTI_INDEX_MEMBER(employee,std::string,name)>,
    ordered_non_unique<
      tag<age>, BOOST_MULTI_INDEX_MEMBER(employee,int,age)> >
> employee_set;

employee_set es;

In my opinion, the variant with make-methods is much better. Why not support for these methods on the library side?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions