Monday, October 30, 2017

C++17: std::invoke

C++17 added the std::invoke() function, which takes a callable object and parameters; and calls the callable object with the parameters.

References:


C++17: operator++(bool) was removed

C++17 removed the operator++(bool) function.


C++17: Logical operator traits

C++17 added the type traits: conjunction, disjunction, and negation.

References:


C++17: std::byte

C++17 added the std::byte type, which is neither a character nor a mathematical object.  It represents only a collection of bits.

References:


C++17: tagged union container

C++17 added a tagged union container. It is called std::variant. Here is an example:

#include <iostream>
#include <variant>

int main()
{
  std::variant<short, int, std::string> myVariant;

  myVariant = (short)1;

  std::cout << std::get<short>(myVariant) << " ";
  std::cout << std::get<0    >(myVariant) << " ";

  myVariant = 2;
  std::cout << std::get<int>(myVariant) << " ";
  std::cout << std::get<1  >(myVariant) << " ";

  myVariant = std::string("Three");
  std::cout << (std::get<std::string>(myVariant)).c_str() << " ";
  std::cout << (std::get<2          >(myVariant)).c_str() << " ";

  std::cout << std::endl;
  return 0;
}
// Output: 1 1 2 2 Three Three
References:
https://en.wikipedia.org/wiki/C%2B%2B17
http://en.cppreference.com/w/cpp/utility/variant

C++17: Bessel functions

C++17 added the following Bessel functions:

regular modified cylindrical Bessel functions 
cyl_bessel_i
cyl_bessel_if
cyl_bessel_il

cylindrical Bessel functions (of the first kind)  
cyl_bessel_j
cyl_bessel_jf
cyl_bessel_jl
  
irregular modified cylindrical Bessel functions 
cyl_bessel_k
cyl_bessel_kf
cyl_bessel_kl
  
spherical Bessel functions (of the first kind) 
sph_bessel
sph_besself
sph_bessell
References:
https://en.wikipedia.org/wiki/C%2B%2B17
http://en.cppreference.com/w/cpp/numeric/special_math

C++17: elliptic integrals

C++17 added the following elliptic integral functions:

(complete) elliptic integral of the first kind 
comp_ellint_1
comp_ellint_1f
comp_ellint_1l
 
(complete) elliptic integral of the second kind 
comp_ellint_2
comp_ellint_2f
comp_ellint_2l
  
(complete) elliptic integral of the third kind 
comp_ellint_3
comp_ellint_3f
comp_ellint_3l
  
(incomplete) elliptic integral of the first kind 
ellint_1
ellint_1f
ellint_1l
  
(incomplete) elliptic integral of the second kind 
ellint_2
ellint_2f
ellint_2l
  
(incomplete) elliptic integral of the third kind 
ellint_3
ellint_3f
ellint_3l
References:
https://en.wikipedia.org/wiki/C%2B%2B17
http://en.cppreference.com/w/cpp/numeric/special_math
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1422.html