-1

One can call sph_legendre from tr1 and compile it with gcc-5 or gcc-6

#include<tr1/cmath>

int main()
{
    std::tr1::sph_legendre(1,1,0);
    return 0;
} 

Unfortunately, if I try to compile it with clang++ as:

clang++ -stdlib=libstdc++ legendre.cpp -o legendre

I get

error: no member named 'sph_legendre' in namespace 'std::tr1'

In the section 40.3, The C++PP (4th edition) states:

"There is a separate ISO standard for special mathematical functions [C++Math,2010]. An implementation may add these functions to cmath"

How can I compile these special functions with clang++?

ilciavo
  • 3,069
  • 7
  • 26
  • 40
  • Try just `std::sph_legendre` see the example: http://en.cppreference.com/w/cpp/numeric/special_math/sph_legendre . __tr1__ was out in 2005/2007 things have moved on. – Richard Critten Mar 25 '17 at 14:59
  • Clang does not ship the TR1. Don't use the TR1. – Kerrek SB Mar 25 '17 at 15:02
  • @RichardCritten If you run that example `sph_legendre` is not a member of `std` even with `gcc-6.1` and `c++17` – ilciavo Mar 25 '17 at 15:09
  • @KerrekSB I'm trying to find a solution for a piece of code that I didn't write – ilciavo Mar 25 '17 at 19:30
  • @ilciavo: If you absolutely cannot change any of the code, you may be out of luck. You could try to find another TR1 implementer. Not sure if the Boost version can be used as a drop-in replacement. Otherwise, the functions themselves are also implemented in GSL. – Kerrek SB Mar 25 '17 at 19:43

1 Answers1

5

As Richard already mentioned, clang does not support std::sph_legendre at the moment.

A possible workaround for you is to use the boost libraries (http://www.boost.org) and include header: boost/math/tr1.hpp

Hubi
  • 1,629
  • 15
  • 20