Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in C only
Search
Advanced Search
Forums
Product Launch
Updates
Today's Posts
Member List
Calendar
Home
Forum
Topic
C
bool equation
Collapse
This topic is closed.
X
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
thomas
#1
bool equation
Aug 10 '08, 12:55 AM
for c++ stl, is there any container or algorithm that can help
calculate result of a bool expression?
e.g.
input: 1&&~0&&0||1
output: 1
joseph cook
#2
Aug 10 '08, 02:35 AM
Re: bool equation
On Aug 9, 8:45 pm, thomas <FreshTho...@gm ail.comwrote:
for c++ stl, is there any container or algorithm that can help
calculate result of a bool expression?
>
e.g.
input: 1&&~0&&0||1
output: 1
Did you try just that?
int main()
{
bool answer = 1&&~0&&0||1; // Ta Da!
// that's it.
}
you could be cute and even get this answer printed to your screen at
compile time. (i.e. you don't even have to run the program).
something like:
template<typena me A>
class Answer {
private:
Answer(){}
};
int main()
{
const bool answer = 1&&~0&&0||1;
Answer<answeris ;
}
The answer will appear in the error message you receive trying to
compile the program.
Joe Cook
Comment
Post
Cancel
Ian Collins
#3
Aug 10 '08, 02:45 AM
Re: bool equation
thomas wrote:
for c++ stl, is there any container or algorithm that can help
calculate result of a bool expression?
>
e.g.
input: 1&&~0&&0||1
output: 1
No, not in standard C++. You'd have to write a simple parser.
--
Ian Collins.
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment