|
Boost Users : |
Subject: [Boost-users] Using object_pool with a constructor with more that 3 arguments with MSVC
From: Pico Geyer (picogeyer_at_[hidden])
Date: 2012-08-23 13:02:33
Hi all.
I'm using object pools in some code of mine. The code needs to build
on unix (gcc) and on Windows(Visual C++).
The objects that I'm constructing take 4 arguments so I needed to use
the scripts mentioned in the note on this page:
http://www.boost.org/doc/libs/1_51_0/libs/pool/doc/html/boost/object_pool.html
<quote>
Since the number and type of arguments to this function is totally
arbitrary, a simple system has been set up to automatically generate
template construct functions. This system is based on the macro
preprocessor m4, which is standard on UNIX systems and also available
for Win32 systems.
detail/pool_construct.m4, when run with m4, will create the file
detail/pool_construct.ipp, which only defines the construct functions
for the proper number of arguments. The number of arguments may be
passed into the file as an m4 macro, NumberOfArguments; if not
provided, it will default to 3.
For each different number of arguments (1 to NumberOfArguments), a
template function is generated. There are the same number of template
parameters as there are arguments, and each argument's type is a
reference to that (possibly cv-qualified) template argument. Each
possible permutation of the cv-qualifications is also generated.
Because each permutation is generated for each possible number of
arguments, the included file size grows exponentially in terms of the
number of constructor arguments, not linearly. For the sake of
rational compile times, only use as many arguments as you need.
detail/pool_construct.bat and detail/pool_construct.sh are also
provided to call m4, defining NumberOfArguments to be their
command-line parameter. See these files for more details."
</quote>
So I ran this script like so:
./pool_construct.sh 4
And I made sure that Visual C++ is using the right include directory.
But I still get the error:
error C2660: 'boost::object_pool<T>::construct' : function does not
take 4 arguments
I then starting digging into the header files to see why
pool_construct.ipp is not being included. I then found these two
interesting parts in object_pool.hpp:
#if defined(BOOST_MSVC) || defined(__KCC)
# define BOOST_NO_TEMPLATE_CV_REF_OVERLOADS
#endif
and
#ifndef BOOST_NO_TEMPLATE_CV_REF_OVERLOADS
# include <boost/pool/detail/pool_construct.ipp>
#else
# include <boost/pool/detail/pool_construct_simple.ipp>
#endif
I don't really understand why the pool_construct_simple.ipp file
should instead be included for windows.
But if there is a good reason for it, shouldn't the documentation be
updated to tell you to instead run the pool_construct_simple.sh script
instead?
Can anyone provide any information to help me understand this?
Thanks in advance.
Pico
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net