$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: [boost] [MPL] "Unwrap" metafunction
From: Robert Kawulak (robert.kawulak_at_[hidden])
Date: 2011-12-29 16:52:12
Hi,
I need a metafunction to check if a type is wrapped as an argument of a
template and "unwrap" it if so. Something like:
template <template <typename> class T, typename C>
struct unwrap {
typedef C type;
static const bool is_wrapped = false;
};
template <template <typename> class T, typename C>
struct unwrap<T, T<C>> {
typedef C type;
static const bool is_wrapped = true;
};
So both unwrap<x, int>::type and unwrap<x, x<int>>::type are int, while
unwrap<x, y<int>>::type is y<int>. Of course I can use the code above, but
I'm just curious - does Boost.MPL already provide a utility that can be used
to achieve the same?
Thanks and best regards,
Robert