Author: sebor
Date: Sun Jan 1 16:15:01 2006
New Revision: 360600
URL: http://svn.apache.org/viewcvs?rev=360600&view=rev
Log:
2006-01-01 Martin Sebor <[EMAIL PROTECTED]>
* alg_test.h (conv_to_bool): Enhanced to prevent default construction
and assignment and replaced conversion to bool with one to a unique
pointer type testable in the controlling expression of the if statement
as required in 25, p7.
Modified:
incubator/stdcxx/trunk/tests/include/alg_test.h
Modified: incubator/stdcxx/trunk/tests/include/alg_test.h
URL:
http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/include/alg_test.h?rev=360600&r1=360599&r2=360600&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/include/alg_test.h (original)
+++ incubator/stdcxx/trunk/tests/include/alg_test.h Sun Jan 1 16:15:01 2006
@@ -260,20 +260,28 @@
// type used to exercise that algorithms do not apply operators
// to function objects the latter are not required to define
-struct conv_to_bool {
-
+struct conv_to_bool
+{
static conv_to_bool make (bool val) {
- conv_to_bool tmp;
- tmp.val_ = val;
- return tmp;
+ return conv_to_bool (val);
}
- operator bool () const {
- return val_;
+ // unique pointer not compatible with any other
+ typedef bool conv_to_bool::*UniquePtr;
+
+ // strictly convertible to a Boolean value testable
+ // in the controlling expression of the if statement
+ // as required in 25, p7
+ operator UniquePtr () const {
+ return val_ ? &conv_to_bool::val_ : UniquePtr (0);
}
private:
- void operator!() const; // not defined
+ // not (publicly) Default-Constructible
+ conv_to_bool (bool val): val_ (val) { }
+
+ void operator= (conv_to_bool); // not Assignable
+ void operator!() const; // not defined
bool val_;
};