[Boost-bugs] [Boost C++ Libraries] #5637: use of mpl::print imposes default constructible requirement on argument

Subject: [Boost-bugs] [Boost C++ Libraries] #5637: use of mpl::print imposes default constructible requirement on argument
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-06-24 01:00:34


#5637: use of mpl::print imposes default constructible requirement on argument
------------------------------+---------------------------------------------
 Reporter: ramey | Owner: dave
     Type: Tasks | Status: new
Milestone: To Be Determined | Component: mpl
  Version: Boost 1.46.1 | Severity: Problem
 Keywords: mpl print |
------------------------------+---------------------------------------------
 I'm using the following to debug some TMP code that looks like the
 following.
 {{{
 #include <boost/mpl/print.hpp>
 struct X {
     X(int);
 };

 boost::mpl::print<
     X
>::type x;

 boost::mpl::print<
     X
>::type y;
 }}}

 I get an error message that the type X is not default constructible. A
 little investigation yields the definition of mpl::print (simplified for
 exposition)

 {{{
 template <class T>
 struct print : identity<T>
 {
     enum { n = sizeof(T) + -1 };
 };
 }}}

 So invoking the print creates an instance with the default constructor
 which provokes the error in this case. For my purposes, I made the
 following change which seems to address the problem:

 {{{
 template <class T>
 struct print : identity<T *>
 {
     enum { n = sizeof(T) + -1 };
 };
 }}}

 I'm using MSVC 9.0.

 A couple of misceleanous issues besides this:

 On my current version of GCC - 4.3.4 I get no warning at all.

 If the same type is printed more than once, I only get the warning on the
 first instance.

 Robert Ramey

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5637>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:06 UTC