Subject: [Boost-bugs] [Boost C++ Libraries] #7230: access to private method using boost::bind
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-08-14 15:21:52
#7230: access to private method using boost::bind
------------------------------+---------------------------------------------
Reporter: anonymous | Owner: pdimov
Type: Bugs | Status: new
Milestone: To Be Determined | Component: bind
Version: Boost 1.49.0 | Severity: Problem
Keywords: bind |
------------------------------+---------------------------------------------
It appears that the privacy of a class method is violated with the use of
boost::bind in a template class.
$ uname -a
Linux myhost.mydomain 2.6.32-220.13.1.el6.x86_64 #1 SMP Thu Mar 29
11:46:40 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux
$ g++ --version
g++ (GCC) 4.4.6 20110731 (Red Hat 4.4.6-3)
{{{
#include <boost/bind.hpp>
#include <iostream>
class base
{
private:
void _private() { std::cout << "private" << std::endl; }
};
template<class T>
class templ
{
public:
void onPrivate(T* t) {
// boost::bind(&T::_private, t)(); // error: âvoid base::_private()â
is private
boost::bind(&base::_private, t)();
}
};
int main(int argc, char **argv)
{
base b;
templ<base> ab;
ab.onPrivate(&b); // got into the private parts :)
// boost::bind(&base::_private, &b)(); // error: âvoid base::_private()â
is private
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/7230> 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:10 UTC