CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

View Poll Results: Do you use 'and' 'or' 'xor' in place of && || ^

Voters
20. You may not vote on this poll
  • Yes

    1 5.00%
  • No

    14 70.00%
  • I didn't know they were alternatives.

    5 25.00%
Results 1 to 13 of 13
  1. #1
    Join Date
    Jul 2002
    Location
    Portsmouth. United Kingdom
    Posts
    2,727

    Do you use 'and' 'or' 'xor'?

    Here's a poll inspired from a recent post.

    Do you use 'and' 'or' 'xor' in place of && || ^
    "It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
    Richard P. Feynman

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: Do you use 'and' 'or' 'xor'?

    not used
    sorry, I meant: !used
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  3. #3
    Join Date
    Nov 2006
    Location
    Essen, Germany
    Posts
    1,344

    Re: Do you use 'and' 'or' 'xor'?

    No, I donĀ“t.
    - Guido

  4. #4
    Join Date
    Jul 2002
    Posts
    2,543

    Re: Do you use 'and' 'or' 'xor'?

    No.
    I guess VB programming learning C++ may use this.

  5. #5
    Join Date
    May 2009
    Posts
    2,413

    Re: Do you use 'and' 'or' 'xor'?

    Quote Originally Posted by JohnW@Wessex View Post
    Do you use 'and' 'or' 'xor' in place of && || ^
    What do you mean by this? Is this some non-standard feature supported by some compiler?

  6. #6
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: Do you use 'and' 'or' 'xor'?

    Quote Originally Posted by nuzzle
    What do you mean by this? Is this some non-standard feature supported by some compiler?
    JohnW@Wessex is talking about certain alternative tokens that are supported by any standard compliant C++ compiler and available via <iso646.h> from the C standard library (it might be a C99 only header though).
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  7. #7
    Join Date
    Jul 2002
    Location
    Portsmouth. United Kingdom
    Posts
    2,727

    Re: Do you use 'and' 'or' 'xor'?

    They're part of the standard, but Visual Studio, for example, needs a compiler switch to enable them, as they can break older code.
    "It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
    Richard P. Feynman

  8. #8
    Join Date
    Jul 2002
    Location
    Portsmouth. United Kingdom
    Posts
    2,727

    Re: Do you use 'and' 'or' 'xor'?

    The set of alternatives are...

    Code:
    <%          {
    %>          }
    <:          [
    :>          ]
    %:          #
    %:%:        ##
    and         &&
    bitor       |
    or          ||
    xor         ^
    compl       ~
    bitand      &
    and_eq      &=
    or_eq       |=
    xor_eq      ^=
    not         !
    not_eq      !=
    "It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
    Richard P. Feynman

  9. #9
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: Do you use 'and' 'or' 'xor'?

    Quote Originally Posted by JohnW@Wessex
    The set of alternatives are...
    I note that the first six (the digraphs) should be available by default for C (at least for C99) as well, without needing to include <iso646.h>.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  10. #10
    Join Date
    May 2009
    Posts
    2,413

    Re: Do you use 'and' 'or' 'xor'?

    I had no idea about this.

    I'm using VS 2008 and these additional keywords aren't recognized by the compiler. It works if I include <iso646.h> though.

    Is there some property setting I can use that enables VS 2008 to recognize and highlight those keywords? I've looked but I cannot find anything.

  11. #11
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: Do you use 'and' 'or' 'xor'?

    Quote Originally Posted by nuzzle
    I'm using VS 2008 and these additional keywords aren't recognized by the compiler.
    I tried disabling language extensions and they worked.

    Quote Originally Posted by nuzzle
    It works if I include <iso646.h> though.
    <ciso646> for MSVC9 seems to mainly include <iso646.h>. Its <iso646.h> appears to conditionally define those macros if language extensions are enabled, so perhaps there is no more specific compiler switch than disabling language extensions to enable this without including a header.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  12. #12
    Join Date
    Jul 2002
    Location
    Portsmouth. United Kingdom
    Posts
    2,727

    Re: Do you use 'and' 'or' 'xor'?

    I may be wrong about the compiler switch

    I'm sure I saw mention of it when I copied the list from a web page I found, but I can't find it now.
    "It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
    Richard P. Feynman

  13. #13
    Join Date
    Oct 2005
    Location
    England
    Posts
    803

    Re: Do you use 'and' 'or' 'xor'?

    Quote Originally Posted by Alex F View Post
    No.
    I guess VB programming learning C++ may use this.
    I started life as a VB programmer but prefer using the {|, &&, ^} operators. It is easier to distinguish between operators and operands at a glance.
    Rich

    Visual Studio 2010 Professional | Windows 7 (x64)
    Ubuntu

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured