Opened 8 years ago

Closed 8 years ago

#10315 closed Feature Requests (fixed)

multi_index composite_key find() doesn't work with std::tuple

Reported by: christephan@… Owned by: Joaquín M López Muñoz
Milestone: To Be Determined Component: multi_index
Version: Boost 1.55.0 Severity: Problem
Keywords: Cc:

Description

com_key_index.find (boost::make_tuple(...)) works. While com_key_index.find (std::make_tuple(...)) doesn't compile.

Using gcc4.8.1 with -std=c++11

Sample code:

#include <tuple>
#include <boost/tuple/tuple.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/composite_key.hpp>

using namespace std;
using namespace boost::multi_index;
using namespace boost;

struct Point
{
    string x;
    string y;
    unsigned w;
};

int main()
{
    struct PointX {};
    struct PointYW {};
    multi_index_container<Point,indexed_by<
        ordered_unique <tag<PointX>, member<Point, string, &Point::x>>,
        ordered_unique <tag<PointYW>, composite_key<Point,
            member<Point, string, &Point::y>,
            member<Point, unsigned, &Point::w>
        >>
    >> points;

    points.get<PointX>().emplace (Point{"A", "B", 1});
    points.get<PointYW>().find (std::make_tuple("B", 1));
    return 0;
}

By replacing std::make_tuple --> boost::make_tuple, it does compile.

Change History (3)

comment:1 by Joaquín M López Muñoz, 8 years ago

Type: BugsFeature Requests

Hi Chris,

Yes, composite keys do not interoperate with std::tuples, basically because the former predate the latter by a number of years. Changing this ticket to "feature request". I hope to be able to find some time to do this, but don't hold your breath :-)

in reply to:  1 comment:2 by christephan@…, 8 years ago

Replying to joaquin:

Hi Chris,

Yes, composite keys do not interoperate with std::tuples, basically because the former predate the latter by a number of years. Changing this ticket to "feature request". I hope to be able to find some time to do this, but don't hold your breath :-)

Very thanks~ I'm using boost::make_tuple by now~ The only pity thing is there is no boost::forward_as_tuple~

comment:3 by Joaquín M López Muñoz, 8 years ago

Resolution: fixed
Status: newclosed

Here you go:

https://github.com/boostorg/multi_index/commit/6d6bb7550460503b27da72c2c583344b1e99f50b

I've just pushed the commit, so regression testers might still reveal some glitches uncovered by my local tests; be warned in case you try this yourself locally.

Note: See TracTickets for help on using tickets.