Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-09-19 14:09:16


From: "Howard Hinnant" <hinnant_at_[hidden]>

> On Thursday, September 19, 2002, at 02:11 PM, Iain K.Hanson wrote:
>
> > The only interesting dependacies imho are which libraries are used i.e.
> >
> > config
> > mpl
> > preprocessor
> > static_assert
>
> Agreed. These two:
>
> mpl
> preprocessor
>
> are throwing up a red flag with me. The type traits library was
> intended to be "fundamental" in the sense that it provided a base upon
> which other libs could be built without dragging in a lot of other
> stuff. I've never before envisioned it as "middle-ware".
>
> Do either of mpl or preprocessor depend on type traits? What is the
> motivation for the dependence of type traits on mpl and preprocessor?

The dependence on MPL is there so that the type_traits templates can be
used in mpl lambda expressions on less-conformant compilers. The dependency
is just on some macros which create nested rebind templates and
specializations as needed. If it weren't for this, Aleksey probably would
never have refactored type_traits.

By the way, this results in a HUGE interoperability win for MPL and
type_traits.

The dependence on the preprocessor library is an illusion, sort of.
Take a look at boost/type_traits/detail/is_function_ptr_helper.hpp:

======== schnip ==========
#if defined(BOOST_TT_PREPROCESSING_MODE)
# include "boost/preprocessor/iterate.hpp"
# include "boost/preprocessor/enum_params.hpp"
# include "boost/preprocessor/comma_if.hpp"
#endif

namespace boost {
namespace type_traits {

template <class R>
struct is_function_ptr_helper
{
    BOOST_STATIC_CONSTANT(bool, value = false);
};

#if !defined(BOOST_TT_PREPROCESSING_MODE)
// preprocessor-generated part, don't edit by hand!

=========== schnipp schnipp ==========
<lots of function overloads here>
=========== schnapp schnapp ==========
#else

#undef BOOST_STATIC_CONSTANT
#define BOOST_PP_ITERATION_PARAMS_1 \
    (0, 25, "boost/type_traits/detail/is_function_ptr_helper.hpp")
#include BOOST_PP_ITERATE()

#endif // BOOST_TT_PREPROCESSING_MODE

} // namespace type_traits
} // namespace boost

#endif // BOOST_TT_DETAIL_IS_FUNCTION_PTR_HELPER_HPP_INCLUDED

///// iteration

#else
#define i BOOST_PP_FRAME_ITERATION(1)

template <class R BOOST_PP_COMMA_IF(i) BOOST_PP_ENUM_PARAMS(i,class T)>
struct is_function_ptr_helper<R (*)(BOOST_PP_ENUM_PARAMS(i,T))> {
BOOST_STATIC_CONSTANT(bool, value = true); };

#undef i
#endif // BOOST_PP_IS_ITERATING
========= schnapp ========

BOOST_TT_PREPROCCESSING_MODE is usually not defined. The header contains
the preprocessor code needed to re-generate the
schnipp-schnipp/schnapp-schnapp section

-----------------------------------------------------------
           David Abrahams * Boost Consulting
dave_at_[hidden] * http://www.boost-consulting.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk