[PATCH] D13289: [libc++] Provide additional templates for valarray transcendentals that satisfy the standard synopsis

Petr Pavlu via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 30 06:44:47 PDT 2015


petpav01 created this revision.
petpav01 added a subscriber: cfe-commits.

Libc++ provides valarray transcendentals with replacement types. These functions are implemented either as `template<class _Expr>` or `template<class _Expr1, class _Expr2>`, where `_Expr` can be `__val_expr` or `valarray`.

The patch provides additional function templates for valarray transcendentals that as a parameter use `_Tp` which is a type of elements in the valarray. This is required by the standard and is needed if the user tries to explicitly instantiate the transcendental functions using `_Tp`, for example, `std::abs<int>(int_valarray)`.

New templates do not take an additional `_Expr` parameter and so the functions accept only `valarray` as their parameter. This means that if the user explicitly instantiates these function templates and passes `__val_expr` to them, it first needs to be converted to `valarray` and the benefit of the expression template optimization is not present. No performance is lost in the currently possible case where template parameters are deduced because using `__val_expr` as an argument will lead to instantiation of the already present templates.

http://reviews.llvm.org/D13289

Files:
  include/valarray
  test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/abs_valarray.pass.cpp
  test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/acos_valarray.pass.cpp
  test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/asin_valarray.pass.cpp
  test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_valarray.pass.cpp
  test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_value.pass.cpp
  test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_value_valarray.pass.cpp
  test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan_valarray.pass.cpp
  test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/cos_valarray.pass.cpp
  test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/cosh_valarray.pass.cpp
  test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/exp_valarray.pass.cpp
  test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/log10_valarray.pass.cpp
  test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/log_valarray.pass.cpp
  test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_valarray.pass.cpp
  test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_value.pass.cpp
  test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_value_valarray.pass.cpp
  test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sin_valarray.pass.cpp
  test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sinh_valarray.pass.cpp
  test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sqrt_valarray.pass.cpp
  test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tan_valarray.pass.cpp
  test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tanh_valarray.pass.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13289.36098.patch
Type: text/x-patch
Size: 39911 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150930/7cb29927/attachment-0001.bin>


More information about the cfe-commits mailing list