[C++-sig] Limit On No. Of Constructors?

David Abrahams dave at boost-consulting.com
Thu Nov 14 02:53:54 CET 2002


"Scott A. Smith" <ssmith at magnet.fsu.edu> writes:

> Is there a limit on the number of constructors allowed
> for a single class?

None in the library. It's your compiler which is hosing you.

> I have several defined for one of my classes:
>
> //                                The Class
>
>   class_<SinglePar>("SinglePar", init<>())
>
> //                              Constructors
>
>     .def(init<const SinglePar&>())
>     .def(init<const std::string&, int, const std::string&, const
> std::string&>())
>     .def(init<const std::string&, int,                     const
> std::string&>())
>     .def(init<const std::string&, double,                  const
> std::string&>())
>     .def(init<const std::string&, const std::string&,      const
> std::string&>())
>     .def(init<const std::string&>())
>
> and during compilation (MSVC 6) this will produce the error
> C:\PROGRAM FILES\BOOST\BOOST_1_29_0\boost/type_traits/is_arithmetic.hpp(38)
> : fatal error C1204: compiler limit : internal structure overflow
>         C:\PROGRAM
> FILES\BOOST\BOOST_1_29_0\boost/type_traits/is_scalar.hpp(30) : see reference
> to class template instantiation 'boost::is_arithmetic<class ParameterSet
> const >' being compiled .......
>
> Microsoft has provided no documentation as to what C1204 means. But if I
> comment out one or two of
> the above constructors, then the build works with out problems. It does not
> seem to matter which
> of them I comment out, other than I need only comment out 1 if I choose the
> 2nd or 5th overload
> above, but I need to comment out two if stopping use of any of the others.
>
> If there are no intrinsic limits I'll keep looking and try to make a simple
> example of how
> this failure occurs. The actual errors produced always reference classes
> deeper in my module,
> perhaps this indicates it is not a problem with BP but with some other code,
> but it is quite
> odd that the build errors disappear when I declare fewer constructors (but
> not any one of them
> in particular).

You need to either get a better compiler (even vc7 would be an
improvement), or split your module code across translation units
(source files). To do that, declare a function in another source file
taking a class_<SinglePar>& parameter, and move some of your .def()
calls there.


-- 
                       David Abrahams
   dave at boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution





More information about the Cplusplus-sig mailing list