boostorg / boostorg/multi_index

[Feature request] make wrappers

Open
#44 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
58
Forks
65
Avg merge
3h 1m
Merged PRs (30d)
1

Description

Inspired by `std::make_tuple` for `std::tuple`..
I recently tried to create 4 simple make methods for types from this library:
```
template
ordered_unique make_ordered_unique(T, M)
{
return {};
}

template
ordered_non_unique make_ordered_non_unique(T, M)
{
return {};
}

template
indexed_by make_indexed_by(T...)
{
return {};
}

template
multi_index_container make_multi_index_container(I)
{
return {};
}
```

These methods allow me to write like this:
```
auto es = make_multi_index_container(make_indexed_by(
make_ordered_unique( tag{}, BOOST_MULTI_INDEX_MEMBER(employee,int,id){}),
make_ordered_non_unique( tag{},BOOST_MULTI_INDEX_MEMBER(employee,std::string,name){}),
make_ordered_non_unique( tag{}, 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, BOOST_MULTI_INDEX_MEMBER(employee,int,id)>,
ordered_non_unique<
tag,BOOST_MULTI_INDEX_MEMBER(employee,std::string,name)>,
ordered_non_unique<
tag, 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?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.