|
Boost : |
Subject: Re: [boost] [parameter] function types as named template parameters?
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2009-01-23 09:39:44
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Friday 23 January 2009 00:55 am, David Abrahams wrote:
> on Thu Jan 22 2009, Frank Mori Hess <frank.hess-AT-nist.gov> wrote:
> > Does Boost.Parameter support function types as named template type
> > parameters?
>
> Can you post a minimal example that reproduces this bug? I'm sure
> there's a quick fix.
>
Here you go. If you undefine NAMED_SIGNATURE_PARAMETER, the test works.
Otherwise, it fails to compile (I'm using gcc 4.1.2).
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFJeda65vihyNWuA4URAloCAKCF02pHvbZl8y9foNbyZnoTYY8aywCffI2a
Ue1wHc8ArjMwirdVc7RRZYI=
=f0fd
-----END PGP SIGNATURE-----
--Boundary-00=_6adeJVQIIzrMCZ/
Content-Type: text/x-c++src; charset="iso-8859-1";
name="parameter_function_type_test.cpp"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="parameter_function_type_test.cpp"
// Copyright Frank Mori Hess 2009.
// Distributed under the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_PARAMETER_MAX_ARITY 7
#define NAMED_SIGNATURE_PARAMETER
#include <boost/test/minimal.hpp>
#include <boost/parameter.hpp>
namespace boost
{
namespace fake_signals2
{
template
<
typename Signature,
typename Group = int,
typename GroupCompare = std::less<Group>
>
struct signal
{};
namespace keywords
{
#ifdef NAMED_SIGNATURE_PARAMETER
BOOST_PARAMETER_TEMPLATE_KEYWORD(signature_type)
#endif
BOOST_PARAMETER_TEMPLATE_KEYWORD(group_type)
BOOST_PARAMETER_TEMPLATE_KEYWORD(group_compare_type)
} // namespace keywords
template <
#ifdef NAMED_SIGNATURE_PARAMETER
typename A0,
#else
typename Signature,
#endif
typename A1 = parameter::void_,
typename A2 = parameter::void_
>
class signal_type
{
typedef parameter::parameters<
#ifdef NAMED_SIGNATURE_PARAMETER
parameter::required<keywords::tag::signature_type>,
#endif
parameter::optional<keywords::tag::group_type>,
parameter::optional<keywords::tag::group_compare_type>
> parameter_spec;
public:
// ArgumentPack
typedef typename
parameter_spec::bind<
#ifdef NAMED_SIGNATURE_PARAMETER
A0,
#endif
A1, A2>::type
args;
#ifdef NAMED_SIGNATURE_PARAMETER
typedef typename parameter::binding<args, keywords::tag::signature_type>::type
signature_type;
#else
typedef Signature signature_type;
#endif
typedef typename
parameter::binding<args, keywords::tag::group_type, int>::type group_type;
typedef typename
parameter::binding<args, keywords::tag::group_compare_type, std::less<group_type> >::type
group_compare_type;
typedef signal
<
signature_type,
group_type,
group_compare_type
> type;
};
} // namespace fake_signals2
} // namespace boost
namespace bs2 = boost::fake_signals2;
int test_main(int, char*[])
{
{
using namespace bs2::keywords;
bs2::signal_type<void ()>::type mysig;
bs2::signal<void ()> mysig2;
BOOST_CHECK(typeid(mysig) == typeid(mysig2));
}
{
using namespace bs2::keywords;
bs2::signal_type<double (int), group_compare_type<std::less<float> > >::type mysig;
bs2::signal<double (int), int, std::less<float> > mysig2;
BOOST_CHECK(typeid(mysig) == typeid(mysig2));
}
return 0;
}
--Boundary-00=_6adeJVQIIzrMCZ/--
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk