Jim Smith
2013-06-24 08:37:47 UTC
Hi,
I posted this once in more detail, but didn't see it listed.
I'm interested in an implementation of C++ types std::boolean, std::true,
std::false, and std::bool_intermediate for states that are not true or
false. These types would allow boolean results to be handled using OO
techniques instead of if/else statements. Also, std::bool_intermediate take
into account the superposition of the two boolean states.
An implementation of these types would allow the result of a boolean method
to be handled using multiple dispatch instead of traditional if/else
statements:
(multiple dispatch is explained in Scott Meyers "More Effective C++")
//usage example:
class handler_concept
{
public:
...
void operator()(const std::true<handler_concept>& bt) ;
void operator()(const std::false<handler_concept>& bf) ;
void operator()(const std::bool_intermediate<handler_concept>& bi) ;
...
};
handler_concept hc; // class object that handles boolean states
std::boolean<handler_concept> bln(hc); // creation of std::boolean object
that will invoke method on handler_concept object hc
SomeOperation s_op; // class object with boolean method
bln = s_op.some_bool_function(); // bln is assigned the boolean value
and invokes the method on handler_concept object hc
//end of example
I implemented these boolean types to try the purposed technique. It's more
elegant than if/else and allows each class to define its own meaning of
true or false etc., increasing encapsulation of an application's concepts.
Thanks & Regards,
--James Smith
I posted this once in more detail, but didn't see it listed.
I'm interested in an implementation of C++ types std::boolean, std::true,
std::false, and std::bool_intermediate for states that are not true or
false. These types would allow boolean results to be handled using OO
techniques instead of if/else statements. Also, std::bool_intermediate take
into account the superposition of the two boolean states.
An implementation of these types would allow the result of a boolean method
to be handled using multiple dispatch instead of traditional if/else
statements:
(multiple dispatch is explained in Scott Meyers "More Effective C++")
//usage example:
class handler_concept
{
public:
...
void operator()(const std::true<handler_concept>& bt) ;
void operator()(const std::false<handler_concept>& bf) ;
void operator()(const std::bool_intermediate<handler_concept>& bi) ;
...
};
handler_concept hc; // class object that handles boolean states
std::boolean<handler_concept> bln(hc); // creation of std::boolean object
that will invoke method on handler_concept object hc
SomeOperation s_op; // class object with boolean method
bln = s_op.some_bool_function(); // bln is assigned the boolean value
and invokes the method on handler_concept object hc
//end of example
I implemented these boolean types to try the purposed technique. It's more
elegant than if/else and allows each class to define its own meaning of
true or false etc., increasing encapsulation of an application's concepts.
Thanks & Regards,
--James Smith
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.