diff --git a/CHANGES.md b/CHANGES.md index c38c40af3..1941d5f9e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -25,6 +25,7 @@ This file is a best-effort approach to solving this issue; we will do our best b * (applications) Deprecated attributes `RemoteAddress` and `RemotePort` in UdpClient, UdpTraceClient and UdpEchoClient. They have been combined into a single `Remote` attribute. * (applications) Deprecated attributes `ThreeGppHttpClient::RemoteServerAddress` and `ThreeGppHttpClient::RemoteServerPort`. They have been combined into a single `ThreeGppHttpClient::Remote` attribute. +* (stats) Deprecated ns3::NaN and ns3::isNaN to use std::nan and std::isnan in their place * (wifi) Added a new **ProtectedIfResponded** attribute to `FrameExchangeManager` to disable RTS/CTS protection for stations that have already responded to a frame requiring acknowledgment in the same TXOP, even if such frame had not been protected by RTS/CTS. The default value is true, even though it represents a change with respect to the previous behavior, because it is likely a more realistic choice. * (wifi) Deprecated setters/getters of the {Ht,Vht,He}Configuration classes that trivially set/get member variables, which have been made public and hence accessible to users. diff --git a/src/stats/model/basic-data-calculators.h b/src/stats/model/basic-data-calculators.h index 57ba95748..ae6e61bc2 100644 --- a/src/stats/model/basic-data-calculators.h +++ b/src/stats/model/basic-data-calculators.h @@ -158,12 +158,12 @@ MinMaxAvgTotalCalculator::MinMaxAvgTotalCalculator() m_total = 0; m_squareTotal = 0; - m_meanCurr = NaN; - m_sCurr = NaN; - m_varianceCurr = NaN; + m_meanCurr = std::nan(""); + m_sCurr = std::nan(""); + m_varianceCurr = std::nan(""); - m_meanPrev = NaN; - m_sPrev = NaN; + m_meanPrev = std::nan(""); + m_sPrev = std::nan(""); } template @@ -261,12 +261,12 @@ MinMaxAvgTotalCalculator::Reset() m_total = 0; m_squareTotal = 0; - m_meanCurr = NaN; - m_sCurr = NaN; - m_varianceCurr = NaN; + m_meanCurr = std::nan(""); + m_sCurr = std::nan(""); + m_varianceCurr = std::nan(""); - m_meanPrev = NaN; - m_sPrev = NaN; + m_meanPrev = std::nan(""); + m_sPrev = std::nan(""); // end MinMaxAvgTotalCalculator::Reset } diff --git a/src/stats/model/data-calculator.cc b/src/stats/model/data-calculator.cc index 1bee2335d..84013ed53 100644 --- a/src/stats/model/data-calculator.cc +++ b/src/stats/model/data-calculator.cc @@ -15,8 +15,8 @@ using namespace ns3; NS_LOG_COMPONENT_DEFINE("DataCalculator"); -static double zero = 0; -const double ns3::NaN = zero / zero; +// NS_DEPRECATED_3_44 +const double ns3::NaN = std::nan(""); //-------------------------------------------------------------- //---------------------------------------------- diff --git a/src/stats/model/data-calculator.h b/src/stats/model/data-calculator.h index 8068d3b86..d3647a4d1 100644 --- a/src/stats/model/data-calculator.h +++ b/src/stats/model/data-calculator.h @@ -9,12 +9,14 @@ #ifndef DATA_CALCULATOR_H #define DATA_CALCULATOR_H +#include "ns3/deprecated.h" #include "ns3/nstime.h" #include "ns3/object.h" #include "ns3/simulator.h" namespace ns3 { +NS_DEPRECATED_3_44("Use std::nan(\"\") instead") extern const double NaN; //!< Stored representation of NaN /** @@ -22,10 +24,12 @@ extern const double NaN; //!< Stored representation of NaN * @param x * @return whether x is NaN */ +NS_DEPRECATED_3_44("Use std::isnan() instead") + inline bool isNaN(double x) { - return x != x; + return std::isnan(x); } class DataOutputCallback; diff --git a/src/stats/model/omnet-data-output.cc b/src/stats/model/omnet-data-output.cc index de936116f..d77fa09e1 100644 --- a/src/stats/model/omnet-data-output.cc +++ b/src/stats/model/omnet-data-output.cc @@ -157,31 +157,31 @@ OmnetDataOutput::OmnetOutputCallback::OutputStatistic(std::string context, name = "\"\""; } (*m_scalar) << "statistic " << context << " " << name << std::endl; - if (!isNaN(statSum->getCount())) + if (!std::isnan(statSum->getCount())) { (*m_scalar) << "field count " << statSum->getCount() << std::endl; } - if (!isNaN(statSum->getSum())) + if (!std::isnan(statSum->getSum())) { (*m_scalar) << "field sum " << statSum->getSum() << std::endl; } - if (!isNaN(statSum->getMean())) + if (!std::isnan(statSum->getMean())) { (*m_scalar) << "field mean " << statSum->getMean() << std::endl; } - if (!isNaN(statSum->getMin())) + if (!std::isnan(statSum->getMin())) { (*m_scalar) << "field min " << statSum->getMin() << std::endl; } - if (!isNaN(statSum->getMax())) + if (!std::isnan(statSum->getMax())) { (*m_scalar) << "field max " << statSum->getMax() << std::endl; } - if (!isNaN(statSum->getSqrSum())) + if (!std::isnan(statSum->getSqrSum())) { (*m_scalar) << "field sqrsum " << statSum->getSqrSum() << std::endl; } - if (!isNaN(statSum->getStddev())) + if (!std::isnan(statSum->getStddev())) { (*m_scalar) << "field stddev " << statSum->getStddev() << std::endl; } diff --git a/src/stats/model/sqlite-data-output.cc b/src/stats/model/sqlite-data-output.cc index 6f406db00..4d3991d4a 100644 --- a/src/stats/model/sqlite-data-output.cc +++ b/src/stats/model/sqlite-data-output.cc @@ -158,23 +158,23 @@ SqliteDataOutput::SqliteOutputCallback::OutputStatistic(std::string key, NS_LOG_FUNCTION(this << key << variable << statSum); OutputSingleton(key, variable + "-count", static_cast(statSum->getCount())); - if (!isNaN(statSum->getSum())) + if (!std::isnan(statSum->getSum())) { OutputSingleton(key, variable + "-total", statSum->getSum()); } - if (!isNaN(statSum->getMax())) + if (!std::isnan(statSum->getMax())) { OutputSingleton(key, variable + "-max", statSum->getMax()); } - if (!isNaN(statSum->getMin())) + if (!std::isnan(statSum->getMin())) { OutputSingleton(key, variable + "-min", statSum->getMin()); } - if (!isNaN(statSum->getSqrSum())) + if (!std::isnan(statSum->getSqrSum())) { OutputSingleton(key, variable + "-sqrsum", statSum->getSqrSum()); } - if (!isNaN(statSum->getStddev())) + if (!std::isnan(statSum->getStddev())) { OutputSingleton(key, variable + "-stddev", statSum->getStddev()); }