|
Boost Users : |
From: Jochen Hammann (jochen.hammann_at_[hidden])
Date: 2005-02-17 04:02:08
Hi,
I am using the Boost MultiIndex container in conjunction with the Microsoft Visual C++ 7.1 compiler.
I encountered an runtime exception during some tests of my application. I made the mistake, that I
tried to construct an index as a separate object instead of using a reference to the respective index.
The MultiIndex documentation highlights this issue:
"Note that get returns a reference to the index, and not an index object. Indices cannot be
constructed as separate objects from the container they belong to, so the following
// Wrong: we forgot the & after employee_set::nth_index<1>::type
const employee_set::nth_index<1>::type name_index=es.get<1>();
does not compile, since it is trying to construct the index object name_index. This is a common
source of errors in user code."
I could reproduce the exception by using the MultiIndex example basic.cpp from the Boost 1.32.0
release. Unfortunately, Microsoft Visual C++ 7.1 compiles the above mentioned line without an error
or warning. During the execution of the example an exception will be thrown while processing the
following line:
std::copy(i.begin(),i.end(),std::ostream_iterator<value_type>(std::cout));
within the function template print_out_by().
Regards,
Jochen.
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