Is there is any difference between using a std::tuple
and a data-only struct
?
typedef std::tuple foo_t;
s
As far as the "generic function" go, Boost.Fusion deserves some love... and especially BOOST_FUSION_ADAPT_STRUCT.
Ripping from the page: ABRACADBRA
namespace demo
{
struct employee
{
std::string name;
int age;
};
}
// demo::employee is now a Fusion sequence
BOOST_FUSION_ADAPT_STRUCT(
demo::employee
(std::string, name)
(int, age))
This means that all Fusion algorithms are now applicable to the struct demo::employee
.
EDIT: Regarding the performance difference or layout compatibility, tuple
's layout is implementation defined so not compatible (and thus you should not cast between either representation) and in general I would expect no difference performance-wise (at least in Release) thanks to the inlining of get
.