|
Boost : |
Subject: Re: [boost] [unordered] Buffered functions?
From: Howard Hinnant (hinnant_at_[hidden])
Date: 2008-12-28 11:06:30
On Dec 28, 2008, at 1:25 AM, David Abrahams wrote:
> The conundrum here is that if we use that technique for tuple, then a
> tuple of empty types can never be empty itself. I'm starting to get
> ill
> just thinking about a generic framework for composing "logically
> empty"
> types that undoes this "EBO erasure" effect when necessary.
Perhaps I'm misunderstanding. Reverting from English to C++ in the
hopes of clarification. :-) The C++0X program and its output below
look quite reasonable to me:
#include <tuple>
#include <type_traits>
#include <cstdio>
struct empty1 {};
struct empty2 {};
struct empty3 {};
int main()
{
typedef std::tuple<empty1> T1;
std::printf("is_empty<tuple<empty1>> = %d\n",
std::is_empty<T1>::value);
typedef std::tuple<empty1, empty2> T2;
std::printf("is_empty<tuple<empty1, empty2>> = %d\n",
std::is_empty<T2>::value);
typedef std::tuple<T2, empty3> T3;
std::printf("is_empty<tuple<tuple<empty1, empty2>, empty3>> = %d
\n", std::is_empty<T3>::value);
typedef std::tuple<int, T3> T4;
std::printf("is_empty<tuple<int, tuple<tuple<empty1, empty2>,
empty3>>> = %d\n", std::is_empty<T4>::value);
std::printf("sizeof(int) = %zu, sizeof(tuple<int,
tuple<tuple<empty1, empty2>, empty3>>) = %zu\n", sizeof(int),
sizeof(T4));
}
is_empty<tuple<empty1>> = 1
is_empty<tuple<empty1, empty2>> = 1
is_empty<tuple<tuple<empty1, empty2>, empty3>> = 1
is_empty<tuple<int, tuple<tuple<empty1, empty2>, empty3>>> = 0
sizeof(int) = 4, sizeof(tuple<int, tuple<tuple<empty1, empty2>,
empty3>>) = 4
I currently favor the "shallow hierarchy" design Doug outlined in c+
+std-lib-18989. Though EMO isn't shown in that description, it is
pretty simple to add to that design.
-Howard
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk