I get the following warnings when I use boost::function with CW 8.2 on W2k: Warning : variable / argument 'deprecated' is not used in function (included from: function10.hpp:28 function.hpp:37 Test.cpp:8) function_template.hpp line 388 BOOST_FUNCTION_DEPRECATED_INNER Warning : variable / argument 'deprecated' is not used in function function.hpp line 874 BOOST_FUNCTION_DEPRECATED_INNER Warning : variable / argument 'deprecated' is not used in function function.hpp line 867 BOOST_FUNCTION_DEPRECATED_INNER I'm using a relatively new CVS snapshot (<2 days old). -- Free Crypto Token - FCT www.FreeCryptoToken.org
On Monday 09 September 2002 08:21 am, Bertolt Mildner wrote:
Warning : variable / argument 'deprecated' is not used in function (included from: function10.hpp:28 function.hpp:37 Test.cpp:8) function_template.hpp line 388 BOOST_FUNCTION_DEPRECATED_INNER
The 'set' method is deprecated and will disappear some time after 1.29.0. Please use the assignment operator instead. Doug
"Douglas Gregor"
On Monday 09 September 2002 08:21 am, Bertolt Mildner wrote:
Warning : variable / argument 'deprecated' is not used in function (included from: function10.hpp:28 function.hpp:37 Test.cpp:8) function_template.hpp line 388 BOOST_FUNCTION_DEPRECATED_INNER
The 'set' method is deprecated and will disappear some time after 1.29.0. Please use the assignment operator instead.
Hmm... I'm not using a set method!? -- Free Crypto Token - FCT www.FreeCryptoToken.org
On Monday 09 September 2002 12:55 pm, Bertolt Mildner wrote:
"Douglas Gregor"
schrieb im Newsbeitrag news:200209090847.39513.gregod@cs.rpi.edu... On Monday 09 September 2002 08:21 am, Bertolt Mildner wrote:
Warning : variable / argument 'deprecated' is not used in function (included from: function10.hpp:28 function.hpp:37 Test.cpp:8) function_template.hpp line 388 BOOST_FUNCTION_DEPRECATED_INNER
The 'set' method is deprecated and will disappear some time after 1.29.0. Please use the assignment operator instead.
Hmm... I'm not using a set method!?
Now I'm completely confused... does code like the following cause a warning? (I don't have access to this compiler, unfortunately, but there aren't any warnings in the Boost regression tests...) template<typename T> struct foo { void bar() { int deprecated; } }; int main() { return sizeof(foo); } You may also compile with BOOST_FUNCTION_NO_DEPRECATED defined, which will completely remove all deprecated functionality. Doug
[...]
Now I'm completely confused... does code like the following cause a warning? (I don't have access to this compiler, unfortunately, but there aren't any warnings in the Boost regression tests...)
template<typename T> struct foo { void bar() { int deprecated; } };
int main() { return sizeof(foo); }
At least with my compiler settings it will! Warning : variable / argument 'deprecated' is not used in function hello.cpp line 51 void bar() { int deprecated; } Error : illegal type hello.cpp line 74 return sizeof(foo);
You may also compile with BOOST_FUNCTION_NO_DEPRECATED defined, which will completely remove all deprecated functionality.
Thanks, that helped a lot! BTW: I also have the problem that I can't use Boost.Function together with precompiled headers because of the following error: Error : illegal use of precompiled header (included from: function.hpp:22 KeyStorage.h:12 HostMemoryKeyStorage.h:9 DesKey.h:11 MWPrefixWin32.pch++:14) function_base.hpp line 288 void nonnull() {}; I have tried to make nonnull() inline and/or static but that didn't help. I think the root of the problem is that the address of nonnull() is taken. I wonder if it is really needed to return a real (member) function pointer or if it would be OK to just return (safe_bool)1 ? Bertolt -- Free Crypto Token - FCT www.FreeCryptoToken.org
[...]
I have tried to make nonnull() inline and/or static but that didn't help. I think the root of the problem is that the address of nonnull() is taken. I wonder if it is really needed to return a real (member) function pointer or if it would be OK to just return (safe_bool)1 ?
Don't know if this is useful but at least it makes my compiler more happy ... diff -r1.33 function_base.hpp 287,291c287 < struct dummy { < void nonnull() {}; < }; < < typedef void (dummy::*safe_bool)(); ---
typedef void (*safe_bool)();
295c291 < { return (this->empty())? 0 : &dummy::nonnull; } ---
{ return (this->empty())? 0 : (safe_bool)~0; }
298c294 < { return (this->empty())? &dummy::nonnull : 0; } ---
{ return (this->empty())? (safe_bool)~0 : 0; }
-- Free Crypto Token - FCT www.FreeCryptoToken.org
On Tuesday 10 September 2002 08:29 am, Bertolt Mildner wrote:
[...]
I have tried to make nonnull() inline and/or static but that didn't help. I think the root of the problem is that the address of nonnull() is taken. I wonder if it is really needed to return a real (member) function pointer or if it would be OK to just return (safe_bool)1 ?
Don't know if this is useful but at least it makes my compiler more happy [snip]
{ return (this->empty())? 0 : (safe_bool)~0; } { return (this->empty())? (safe_bool)~0 : 0; }
Unfortunately, that invokes implementation-defined behavior, because (safe_bool)~0 may or may not be the null pointer. Perhaps if we made nonnull a function template it would make precompiled headers possible again... (I _really_ wish I had this compiler to try things on, but thanks for helping out!) Doug
"Douglas Gregor"
On Tuesday 10 September 2002 08:29 am, Bertolt Mildner wrote:
[...]
I have tried to make nonnull() inline and/or static but that didn't help. I think the root of the problem is that the address of nonnull() is taken. I wonder if it is really needed to return a real (member) function pointer or if it would be OK to just return (safe_bool)1 ?
Don't know if this is useful but at least it makes my compiler more happy [snip]
{ return (this->empty())? 0 : (safe_bool)~0; } { return (this->empty())? (safe_bool)~0 : 0; }
Unfortunately, that invokes implementation-defined behavior, because (safe_bool)~0 may or may not be the null pointer. [...]
Is really only a valid (member) function pointer guaranteed to be non-null? I think it is very strange that ~0 may not be non-null! I have tried this one: diff -r1.33 function_base.hpp 267a268,275
namespace detail { inline void nonnull() { } }
274c282 < bool empty() const { return !manager; } ---
inline bool empty() const { return !manager; }
284c292 < operator bool () const { return !this->empty(); } ---
inline operator bool () const { return !this->empty(); }
287,291c295 < struct dummy { < void nonnull() {}; < }; < < typedef void (dummy::*safe_bool)(); ---
typedef void (*safe_bool)();
294,295c298,299 < operator safe_bool () const < { return (this->empty())? 0 : &dummy::nonnull; } ---
inline operator safe_bool () const { return (this->empty())? 0 : &detail::nonnull; }
297,298c301,302 < safe_bool operator!() const < { return (this->empty())? &dummy::nonnull : 0; } ---
inline safe_bool operator!() const { return (this->empty())? &detail::nonnull : 0; }
*but*, now I get the following errors:
Error : call of non-function
(instantiating: 'boost::function1
On Tuesday 10 September 2002 10:56 am, Bertolt Mildner wrote:
Is really only a valid (member) function pointer guaranteed to be non-null? I think it is very strange that ~0 may not be non-null!
Yes, it is strange, but it should be possible. For instance, this isn't guaranteed to give a null function pointer: int x = 1; return (safe_bool)(1-x); Only an integral constant expression that is '0', when converted to a pointer, is guaranteed to become the null pointer. You also can't rely on: T* p = 0; int p_int = (int)p; assert(p_int == 0); // p_int need not be zero! Except for the syntactic oddity that '0' can be converted to a null pointer, there need not be a relationship between an integer 0 and the null pointer :)
I have tried this one:
typedef void (*safe_bool)();
You don't want to do that :) safe_bool is a pointer-to-member-function so that it is _only_ useful in boolean contexts. Perhaps this would appease your compiler: struct dummy { template<typename T> void nonnull() {}; }; typedef void (dummy::*safe_bool)(); operator safe_bool () const { return (this->empty())? 0 : &dummy::nonnull<int>; } safe_bool operator!() const { return (!this->empty())? 0 : &dummy::nonnull<int>; } If it works, I'll put the workaround into CVS. Doug
"Douglas Gregor"
On Tuesday 10 September 2002 10:56 am, Bertolt Mildner wrote:
[...]
struct dummy { template<typename T> void nonnull() {}; };
typedef void (dummy::*safe_bool)();
operator safe_bool () const { return (this->empty())? 0 : &dummy::nonnull<int>; }
safe_bool operator!() const { return (!this->empty())? 0 : &dummy::nonnull<int>; }
If it works, I'll put the workaround into CVS.
Now I get: Error : ambiguous access to overloaded function (included from: function.hpp:22 KeyStorage.h:12 HostMemoryKeyStorage.h:9 DesKey.h:10 MWPrefixWin32.pch++:14) function_base.hpp line 298 { return (!this->empty())? 0 : &dummy::nonnull<int>; } -- Free Crypto Token - FCT www.FreeCryptoToken.org
From: "Douglas Gregor"
safe_bool operator!() const { return (!this->empty())? 0 : &dummy::nonnull<int>; }
This is not related to the problem you are discussing, but operator! can (and probably should) return an ordinary bool.
"Peter Dimov"
From: "Douglas Gregor"
safe_bool operator!() const { return (!this->empty())? 0 : &dummy::nonnull<int>; }
This is not related to the problem you are discussing, but operator! can (and probably should) return an ordinary bool.
So bool operator!() const { return !this->empty(); } should be OK? ... two minutes later ... Arghalskfvbafg1q24584%&§/(%§&$%&?!?! CW now gives me the same error in operator safe_bool() ... -- Free Crypto Token - FCT www.FreeCryptoToken.org
From: "Bertolt Mildner"
"Peter Dimov"
schrieb im Newsbeitrag news:004301c258e2$cc559850$1d00a8c0@pdimov2... From: "Douglas Gregor" safe_bool operator!() const { return (!this->empty())? 0 : &dummy::nonnull<int>; }
This is not related to the problem you are discussing, but operator! can (and probably should) return an ordinary bool.
So bool operator!() const { return !this->empty(); } should be OK? ... two minutes later ... Arghalskfvbafg1q24584%&§/(%§&$%&?!?! CW now gives me the same error in operator safe_bool() ...<<< I'm curious... Do you get an error when you put boost/shared_ptr.hpp in a precompiled header?
"Peter Dimov"
From: "Bertolt Mildner"
"Peter Dimov"
schrieb im Newsbeitrag news:004301c258e2$cc559850$1d00a8c0@pdimov2... From: "Douglas Gregor"
[...]
CW now gives me the same error in operator safe_bool() ...<<<
I'm curious... Do you get an error when you put boost/shared_ptr.hpp in a precompiled header?
No, I had no problems with Boost in precompiled headers so far except with Boost.Function. I'm using shared_ptr, BOOST_STATIC_ASSERT, lexical_cast, Boost.Threads, pool allocator, iterator adapters, any, ... Bertolt -- Free Crypto Token - FCT www.FreeCryptoToken.org
"Peter Dimov"
schrieb im Newsbeitrag news:001801c258e7$27b15d20$1d00a8c0@pdimov2... From: "Bertolt Mildner"
"Peter Dimov"
schrieb im Newsbeitrag news:004301c258e2$cc559850$1d00a8c0@pdimov2... From: "Douglas Gregor" [...]
CW now gives me the same error in operator safe_bool() ...<<<
I'm curious... Do you get an error when you put boost/shared_ptr.hpp in a precompiled header?
No, I had no problems with Boost in precompiled headers so far except with Boost.Function.
I'm using shared_ptr, BOOST_STATIC_ASSERT, lexical_cast, Boost.Threads,
From: "Bertolt Mildner"
shared_ptr reuses shared_ptr::get as the nonnull value, without a dummy nested class:
// implicit conversion to "bool"
typedef T * (this_type::*unspecified_bool_type)() const;
operator unspecified_bool_type() const // never throws { return px == 0? 0: &this_type::get; }
Perhaps something along these lines will work for boost::function.
Ok, here is my next try:
diff -r1.33 function_base.hpp
271c271
< function_base() : manager(0), functor(static_cast
inline function_base() : manager(0), functor(static_cast
(0)) {}
274c274 < bool empty() const { return !manager; } ---
inline bool empty() const { return !manager; }
284c284 < operator bool () const { return !this->empty(); } ---
inline operator bool () const { return !this->empty(); }
287,291c287 < struct dummy { < void nonnull() {}; < }; < < typedef void (dummy::*safe_bool)(); ---
typedef bool (function_base::*safe_bool)() const;
294,295c290,294 < operator safe_bool () const < { return (this->empty())? 0 : &dummy::nonnull; } ---
inline operator safe_bool () const { return (this->empty())? 0 : &function_base::empty; }
inline bool operator!() const { return !this->empty(); }
297,298d295 < safe_bool operator!() const < { return (this->empty())? &dummy::nonnull : 0; } which again results in this error: Error : illegal use of precompiled header (included from: function.hpp:22 KeyStorage.h:12 HostMemoryKeyStorage.h:9 DesKey.h:10 MWPrefixWin32.pch++:15) function_base.hpp line 274 inline bool empty() const { return !manager; } Bertolt -- Free Crypto Token - FCT www.FreeCryptoToken.org
[...]
CW now gives me the same error in operator safe_bool() ...<<<
I'm curious... Do you get an error when you put boost/shared_ptr.hpp in a precompiled header?
No, I had no problems with Boost in precompiled headers so far except with Boost.Function.
I'm using shared_ptr, BOOST_STATIC_ASSERT, lexical_cast, Boost.Threads, pool allocator, iterator adapters, any, ...<
shared_ptr reuses shared_ptr::get as the nonnull value, without a dummy nested class:
// implicit conversion to "bool"
typedef T * (this_type::*unspecified_bool_type)() const;
operator unspecified_bool_type() const // never throws { return px == 0? 0: &this_type::get; }
Perhaps something along these lines will work for boost::function.
OK, I think the problem is that function_base is not a template. This should fix it: diff -r1.33 function_base.hpp 268c268,269 < class function_base ---
template <typename do_not_use = int> class function_base_impl 271c272 < function_base() : manager(0), functor(static_cast
(0)) {}
function_base_impl() : manager(0), functor(static_cast
(0)) {}
287,291c288 < struct dummy { < void nonnull() {}; < }; < < typedef void (dummy::*safe_bool)(); ---
typedef bool (function_base_impl<>::*safe_bool)() const;
295c292 < { return (this->empty())? 0 : &dummy::nonnull; } ---
{ return (this->empty())? 0 : &function_base_impl<>::empty; }
297,298c294,295 < safe_bool operator!() const < { return (this->empty())? &dummy::nonnull : 0; } ---
bool operator!() const { return this->empty(); }
300a298,299
typedef function_base_impl<> function_base;
Bertolt -- Free Crypto Token - FCT www.FreeCryptoToken.org
On Tuesday 10 September 2002 12:20 pm, Bertolt Mildner wrote:
Arghalskfvbafg1q24584%&§/(%§&$%&?!?!
CW now gives me the same error in operator safe_bool() ...
\me ponders running out to buy MW 8.2 just to get this working... Yet one more idea (arghhhhh): template<typename T> struct dummy { void nonnull(); }; typedef void (dummy<int>::*safe_bool)(); operator safe_bool() const { return this->empty? 0 : &dummy<int>::nonnull; } bool operator!() const { return this->empty(); } Doug
On Tuesday 10 September 2002 11:57 am, Peter Dimov wrote:
From: "Douglas Gregor"
safe_bool operator!() const { return (!this->empty())? 0 : &dummy::nonnull<int>; }
This is not related to the problem you are discussing, but operator! can (and probably should) return an ordinary bool.
Yes, it should return a bool. Thanks, I'll change this. Doug
participants (3)
-
Bertolt Mildner
-
Douglas Gregor
-
Peter Dimov