This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

3964. std::atan2 and std::pow overloads that take two std::valarray parameters should require the arguments to have the same length

Section: 29.6.3.3 [valarray.transcend] Status: New Submitter: Jiang An Opened: 2023-07-28 Last modified: 2023-10-30

Priority: 4

View all issues with New status.

Discussion:

All binary operation between std::valarrays expect them to have the same length. But std::atan2 and std::pow lack such Preconditions.

[2023-10-30; Reflector poll]

Set priority to 4 after reflector poll. "Also need to say what those functions return." "Paragraph 1 needs a correction for the functions that takes two operands." "And those are arguments not operands."

Proposed resolution:

This wording is relative to N4950.

  1. Modify 29.6.3.3 [valarray.transcend] as indicated:

    template<class T> valarray<T> abs (const valarray<T>&);
    template<class T> valarray<T> acos (const valarray<T>&);
    template<class T> valarray<T> asin (const valarray<T>&);
    template<class T> valarray<T> atan (const valarray<T>&);
    template<class T> valarray<T> atan2(const valarray<T>&, const valarray<T>&);
    template<class T> valarray<T> atan2(const valarray<T>&, const typename valarray<T>::value_type&);
    template<class T> valarray<T> atan2(const typename valarray<T>::value_type&, const valarray<T>&);
    template<class T> valarray<T> cos (const valarray<T>&);
    template<class T> valarray<T> cosh (const valarray<T>&);
    template<class T> valarray<T> exp (const valarray<T>&);
    template<class T> valarray<T> log (const valarray<T>&);
    template<class T> valarray<T> log10(const valarray<T>&);
    template<class T> valarray<T> pow (const valarray<T>&, const valarray<T>&);
    template<class T> valarray<T> pow (const valarray<T>&, const typename valarray<T>::value_type&);
    template<class T> valarray<T> pow (const typename valarray<T>::value_type&, const valarray<T>&);
    template<class T> valarray<T> sin (const valarray<T>&);
    template<class T> valarray<T> sinh (const valarray<T>&);
    template<class T> valarray<T> sqrt (const valarray<T>&);
    template<class T> valarray<T> tan (const valarray<T>&);
    template<class T> valarray<T> tanh (const valarray<T>&);
    

    -1- Mandates: A unique function with the indicated name can be applied (unqualified) to an operand of type T. This function returns a value of type T or which can be unambiguously implicitly converted to type T.

    -?- Preconditions: For atan2 and pow overloads that take two valarray parameters, the corresponding array arguments have the same length.