Subject: Re: [Boost-bugs] [Boost C++ Libraries] #6711: with unordered_map using interprocess basic_string in shared memory, find and [] are annoying
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-03-21 23:00:50
#6711: with unordered_map using interprocess basic_string in shared memory, find
and [] are annoying
----------------------------------+-----------------------------------------
Reporter: jdy@⦠| Owner:
Type: Feature Requests | Status: closed
Milestone: To Be Determined | Component: None
Version: Boost 1.49.0 | Severity: Problem
Resolution: wontfix | Keywords: interprocess, unordered_map, container
----------------------------------+-----------------------------------------
Comment (by danieljames):
It does, because it can break valid code. Consider this:
{{{
#include <cassert>
#include <functional>
struct source {};
struct value {
value(source&&) {}
};
void foo(value const& x) { std::equal_to<value>(x); }
#if defined(ADD_TEMPLATE)
template <typename T>
void foo(T const& x) { std::equal_to<value>(x); }
#endif
int main() {
foo(source());
}
}}}
Note that ADD_TEMPLATE adds a template overload, as you're suggesting.
Defining ADD_TEMPLATE causes it to fail:
{{{
$ g++-mp-4.7 --std=c++0x demo.cpp
$ g++-mp-4.7 --std=c++0x demo.cpp -DADD_TEMPLATE
demo.cpp: In instantiation of 'void foo(const T&) [with T = source]':
demo.cpp:19:17: required from here
demo.cpp:15:24: error: invalid initialization of reference of type 'const
value&' from expression of type 'const source'
demo.cpp:9:6: error: in passing argument 1 of 'void f(const value&)'
}}}
The same could happen if a template overload was added for `find`.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/6711#comment:3> 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:09 UTC