Files
CoolProp/dev/Tickets/870.cpp
Ian Bell bc8c1bc039 C++17 modernization: remove shims, stdlib idioms, attributes, filesystem (#2688)
* chore: C++17 modernization — remove shims, use stdlib idioms

Phase 1 — Mechanical:
- Replace crossplatform_shared_ptr.h with <memory> in all 20 files; delete shim
- Replace NULL with nullptr (~10 occurrences)
- Replace throw() with noexcept (DataStructures.h)
- Convert 30+ iterator for-loops to range-for with auto/structured bindings
- Replace insert(make_pair/pair<>) with emplace/try_emplace (~40 sites)
- Replace shared_ptr<T>(new T) with make_shared<T> (~5 sites)

Phase 2 — Optional/structured bindings:
- get_alternate() returns std::optional<pair<size_t,size_t>>; remove has_valid_neighbor()
- get_set_of_tables() eliminates bool out-param, returns std::pair
- is_inside() switch refactored to IIFE eliminating nullptr-init pattern

Phase 3 — Attributes:
- Remove DEPRECATED macro; use [[deprecated("...")]] directly (PolyMath.h)
- Add [[nodiscard]] to is_inside, valid, calc_saturated_*_keyed_output,
  get_parameter_information/index, generate_update_pair, has_number

Phase 4 — Architectural:
- CPfilepaths.cpp: use std::filesystem on non-Android/Emscripten/powerpc targets
- DataStructures.h: annotate 5 public enums with explicit underlying type (: int)
- get_parameter_information() takes std::string_view for info param

Build: clean, zero errors. Test suite: 100/110 pass (10 known pre-existing failures).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Remove Unicode replacement character (U+FFFD) from 870.cpp

Addresses PR review comment about non-printing character on line 25.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Remove unnecessary <memory> include from IdealCurves.h

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Always use std::filesystem

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 13:28:11 -04:00

26 lines
845 B
C++

#include <memory>
#include <AbstractState.h>
#include <CoolProp.h>
int main(int argc, const char* argv[]) {
shared_ptr<CoolProp::AbstractState> pState;
pState.reset(CoolProp::AbstractState::factory("TTSE&HEOS", "Water"));
std::cout << "T crit: " << pState->T_critical() << std::endl;
pState->update(CoolProp::QT_INPUTS, 0.2, 373.15);
double res = pState->first_two_phase_deriv_splined(CoolProp::iDmass, CoolProp::iHmass, CoolProp::iP, 0.3);
/*x, y1 = [], []
for Q in np.linspace(0, 0.3, steps) :
AS.update(CoolProp.PQ_INPUTS, 101325, Q)
x.append(AS.Q())
try :
y1.append(AS.first_two_phase_deriv_splined(CoolProp.iDmass, CoolProp.iHmass, CoolProp.iP, 0.3))
except Exception as e :
print e
y1.append(np.NAN)
break
plt.plot(x, y1, label = 'Two-phase (splined, tabular)', ls = '--', lw = 3)
*/
}