Remove C++14-isms

Some day this commit will be reverted.
pull/110/head
Hleb Valoshka 2018-08-09 00:03:30 +03:00
parent 83b222013b
commit 4bdfe271e5
6 changed files with 17 additions and 15 deletions

View File

@ -41,7 +41,7 @@ const double astro::SOLAR_POWER = 3.8462e26; // Watts
// Angle between J2000 mean equator and the ecliptic plane.
// 23 deg 26' 21".448 (Seidelmann, _Explanatory Supplement to the
// Astronomical Almanac_ (1992), eqn 3.222-1.
constexpr double astro::J2000Obliquity = degToRad(23.4392911);
const double astro::J2000Obliquity = degToRad(23.4392911);
static const Quaterniond ECLIPTIC_TO_EQUATORIAL_ROTATION = XRotation(-astro::J2000Obliquity);
static const Matrix3d ECLIPTIC_TO_EQUATORIAL_MATRIX = ECLIPTIC_TO_EQUATORIAL_ROTATION.toRotationMatrix();

View File

@ -145,7 +145,7 @@ void Galaxy::setType(const string& typeStr)
{
type = Galaxy::Irr;
auto iter = std::find_if(begin(GalaxyTypeNames), end(GalaxyTypeNames),
[typeStr](auto& g) { return g.name == typeStr; });
[typeStr](GalaxyTypeName& g) { return g.name == typeStr; });
if (iter != end(GalaxyTypeNames))
type = iter->type;

View File

@ -73,7 +73,7 @@ static void InitTrigArrays()
}
static constexpr float getSphereLOD(float discSizeInPixels)
static float getSphereLOD(float discSizeInPixels)
{
if (discSizeInPixels < 10)
return -3.0f;

View File

@ -276,7 +276,7 @@ uint32_t StarDatabase::crossIndex(const Catalog catalog, const uint32_t celCatal
// A simple linear search. We could store cross indices sorted by
// both catalog numbers and trade memory for speed
auto iter = std::find_if(xindex->begin(), xindex->end(),
[celCatalogNumber](auto& o){ return celCatalogNumber == o.celCatalogNumber; });
[celCatalogNumber](CrossIndexEntry& o){ return celCatalogNumber == o.celCatalogNumber; });
if (iter != xindex->end())
return iter->catalogNumber;

View File

@ -707,7 +707,7 @@ static int object_getinfo(lua_State* l)
string featureName("Unknown");
auto iter = std::find_if(CelxLua::LocationFlagMap.begin(),
CelxLua::LocationFlagMap.end(),
[&featureType](auto& it){ return it.second == featureType; });
[&featureType](pair<const string, uint32_t>& it){ return it.second == featureType; });
if (iter != CelxLua::LocationFlagMap.end())
featureName = iter->first;
celx.setTable("featureType", featureName.c_str());

View File

@ -15,12 +15,14 @@
#define PI 3.14159265358979323846
#define CONSTEXPR /**/
// TODO: All of the functions in the 'Math' class should be
// moved to the celmath namespace.
namespace celmath
{
/** Return the natural logarithm of 2 */
template<class T> constexpr T Ln2()
template<class T> CONSTEXPR T Ln2()
{
return (T) 0.693147180559945;
}
@ -52,32 +54,32 @@ typedef Math<float> Mathf;
typedef Math<double> Mathd;
template<class T> constexpr T degToRad(T d)
template<class T> CONSTEXPR T degToRad(T d)
{
return d / 180 * static_cast<T>(PI);
}
template<class T> constexpr T radToDeg(T r)
template<class T> CONSTEXPR T radToDeg(T r)
{
return r * 180 / static_cast<T>(PI);
}
template<class T> constexpr T abs(T x)
template<class T> CONSTEXPR T abs(T x)
{
return (x < 0) ? -x : x;
}
template<class T> constexpr T square(T x)
template<class T> CONSTEXPR T square(T x)
{
return x * x;
}
template<class T> constexpr T cube(T x)
template<class T> CONSTEXPR T cube(T x)
{
return x * x * x;
}
template<class T> constexpr T clamp(T x)
template<class T> CONSTEXPR T clamp(T x)
{
if (x < 0)
return 0;
@ -87,7 +89,7 @@ template<class T> constexpr T clamp(T x)
return x;
}
template<class T> constexpr T sign(T x)
template<class T> CONSTEXPR T sign(T x)
{
if (x < 0)
return -1;
@ -108,12 +110,12 @@ template<class T> T pfmod(T x, T y)
return x - quotient * y;
}
template<class T> constexpr T circleArea(T r)
template<class T> CONSTEXPR T circleArea(T r)
{
return (T) PI * r * r;
}
template<class T> constexpr T sphereArea(T r)
template<class T> CONSTEXPR T sphereArea(T r)
{
return 4 * (T) PI * r * r;
}