Error handling in ValArray containers

Discussion in 'C++' started by jacob navia, Apr 12, 2011.

  1. jacob navia

    jacob navia Guest

    I have some questions concerning ValArrays.

    (1) What happens when you write

    ValArray A,B,C;

    C = A+B;

    and A is of different length than B?

    Is this an error or is it implementation defined?
    Is there an exception defined for this error?

    I have difficulties finding any related information.

    (2) If you have a long double ValArray A, and a float array B
    the expression
    C = A+B
    returns a long double result that is converted to the type of
    C or is there any promotion/demotion rules?


    Thanks in advance.

    jacob
    jacob navia, Apr 12, 2011
    #1
    1. Advertising

  2. jacob navia

    Ian Collins Guest

    On 04/12/11 09:53 PM, jacob navia wrote:
    > I have some questions concerning ValArrays.
    >
    > (1) What happens when you write
    >
    > ValArray A,B,C;
    >
    > C = A+B;
    >
    > and A is of different length than B?
    >
    > Is this an error or is it implementation defined?
    > Is there an exception defined for this error?


    26.3.3.1/3

    If the argument arrays do not have the same length, the behavior is
    undefined.

    > I have difficulties finding any related information.


    Have you checked the standard?

    > (2) If you have a long double ValArray A, and a float array B
    > the expression
    > C = A+B
    > returns a long double result that is converted to the type of
    > C or is there any promotion/demotion rules?


    26.3.3.1/1

    Each of these operators may only be instantiated for a type T to which
    the indicated operator can be applied
    and for which the indicated operator returns a value which is of type T
    or which can be unambiguously converted to type T.

    --
    Ian Collins
    Ian Collins, Apr 12, 2011
    #2
    1. Advertising

  3. jacob navia

    jacob navia Guest

    Le 12/04/11 12:55, Ian Collins a écrit :

    [snip]

    Thanks a lot Ian. I did not find that for stupidity reasons :)
    jacob navia, Apr 12, 2011
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim West
    Replies:
    2
    Views:
    489
    Jim West
    Dec 23, 2003
  2. Replies:
    0
    Views:
    349
  3. holmescn

    a valarray error with mingw

    holmescn, Apr 15, 2007, in forum: C++
    Replies:
    1
    Views:
    304
    Prashanth
    Apr 16, 2007
  4. Replies:
    7
    Views:
    540
    Pete Becker
    Jan 25, 2008
  5. Sebastian Mach
    Replies:
    5
    Views:
    303
Loading...

Share This Page