Skip to content

Implement HighsDynamicLibrary::call in a C++11 & C++20 compatible way - #3110

Closed
hedtke wants to merge 4 commits into
ERGO-Code:latestfrom
hedtke:cpp20
Closed

hedtke wants to merge 4 commits into
ERGO-Code:latestfrom
hedtke:cpp20

Conversation

@hedtke

@hedtke hedtke commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

The usage of std::result_of within the header makes it impossible for this code to compile when the user uses C++20 but has HiGHS as dependency.

Added a new guard to change the function signature to be compatible with C++20 and later.

I tried to create the conan package for this release, but with my local setting of cppstd=20, compilation fails

galabovaa and others added 4 commits June 27, 2026 23:47
The usage of std::result_of within the header makes it impossible for this code to compile when the user uses C++20 but has HiGHS as dependency.
Added a new guard to change the function signature for be compatible with C++20 and later
@codecov

codecov Bot commented Jun 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.16%. Comparing base (9713e3d) to head (e79dc21).

Additional details and impacted files
@@           Coverage Diff           @@
##           latest    #3110   +/-   ##
=======================================
  Coverage   73.15%   73.16%           
=======================================
  Files         430      430           
  Lines      103937   103937           
  Branches    16717    16717           
=======================================
+ Hits        76039    76046    +7     
+ Misses      27622    27615    -7     
  Partials      276      276           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jajhall
jajhall changed the base branch from master to latest June 29, 2026 10:51
@jajhall
jajhall requested a review from mathgeekcoder June 29, 2026 10:54
@jajhall jajhall self-assigned this Jun 29, 2026
@jajhall jajhall added the Enhancement New feature or request label Jun 29, 2026
@galabovaa

Copy link
Copy Markdown
Contributor

The CI looked fine, apart from the julia tests which I modified in the linked PR

@galabovaa

Copy link
Copy Markdown
Contributor

I did reproduce the issue locally and verified that the fix works for the conan build. Will add this to the release tests, thank you @hedtke

@mathgeekcoder

Copy link
Copy Markdown
Collaborator

Thanks @hedtke! The fix is now incorporated into #3114, so we can close this PR without merge. I also changed the code to avoid the preprocessor check, which works for C++11 through to C++20 (and beyond):

  template <typename FuncType, typename... Args>
  auto call(const char* name, Args... args) const
      -> decltype(std::declval<FuncType>()(std::declval<Args>()...)) {
    FuncType func;
    if (!resolve(func, name)) {
      throw std::runtime_error(std::string("Failed to resolve symbol: ") +
                               name);
    }
    return func(args...);
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants