[test] missing friend declaration in class fixed_mapping?

Hello, I'm not really sure but isn't there a friend declaration missing in the fixed_mapping class? Given the following code: template< ... > class fixed_mapping { typedef std::pair<Key,Value> elem_type; ... struct p1 : public std::binary_function<elem_type,Key,bool> { bool operator()( elem_type const& x, Key const& y ) const { return Compare()( x.first, y ); } }; ... }; doesn't this require p1 to be a friend of fixed mapping to be able to access elem_type in it's operator()? This would then give: template< ... > class fixed_mapping { typedef std::pair<Key,Value> elem_type; ... struct p1; friend struct p1; ... struct p1 : public std::binary_function<elem_type,Key,bool> { bool operator()( elem_type const& x, Key const& y ) const { return Compare()( x.first, y ); } }; ... }; Markus

On Thu, Jun 16, 2005 at 11:43:08AM +0200, Markus Sch?pflin wrote:
Hello,
I'm not really sure but isn't there a friend declaration missing in the fixed_mapping class?
Given the following code:
template< ... > class fixed_mapping { typedef std::pair<Key,Value> elem_type; ... struct p1 : public std::binary_function<elem_type,Key,bool> { bool operator()( elem_type const& x, Key const& y ) const { return Compare()( x.first, y ); } }; ... };
doesn't this require p1 to be a friend of fixed mapping to be able to access elem_type in it's operator()?
Strictly, yes. But many compilers implement the resolution to DR45 already: http://www.open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#45 jon

Jonathan Wakely wrote:
On Thu, Jun 16, 2005 at 11:43:08AM +0200, Markus Sch?pflin wrote:
I'm not really sure but isn't there a friend declaration missing in the fixed_mapping class?
Given the following code:
template< ... > class fixed_mapping { typedef std::pair<Key,Value> elem_type; ... struct p1 : public std::binary_function<elem_type,Key,bool> { bool operator()( elem_type const& x, Key const& y ) const { return Compare()( x.first, y ); } }; ... };
doesn't this require p1 to be a friend of fixed mapping to be able to access elem_type in it's operator()?
Strictly, yes. But many compilers implement the resolution to DR45 already: http://www.open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#45
Gennadiy, would you mind if I add the two missing friend declarations (for p1 and p2) to satisfy compilers which require this? Markus

Gennadiy Rozental wrote:
Gennadiy, would you mind if I add the two missing friend declarations (for p1 and p2) to satisfy compilers which require this?
Ok. Go ahead.
Done. I wrapped it in a BOOST_WORKAROUND section, just to be sure not be break anything else. Markus
participants (3)
-
Gennadiy Rozental
-
Jonathan Wakely
-
Markus Schöpflin