Skip to content

Fix std::hash compilation error for gsl::not_null<std::shared_ptr<T>> - #1210

Merged
Carson Radtke (carsonRadtke) merged 6 commits into
mainfrom
copilot/fix-1209
Dec 5, 2025
Merged

Fix std::hash compilation error for gsl::not_null<std::shared_ptr<T>>#1210
Carson Radtke (carsonRadtke) merged 6 commits into
mainfrom
copilot/fix-1209

Conversation

Copilot AI commented Jun 2, 2025

Copy link
Copy Markdown
Contributor
  • Fix std::hash compilation error for gsl::not_null with shared_ptr
  • Add comment explaining safe usage of typename T::element_type in not_null_hash
  • Rebase changes onto main to re-trigger CI tests
  • Remove upgrade_checklist.md file as requested

All changes have been successfully rebased onto the latest main branch and unnecessary file has been removed.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Compilation error with std::hash<gsl::not_null<std::shared_ptr<T>>> in GSL 4.2.0 Fix std::hash compilation error for gsl::not_null<std::shared_ptr<T>> Jun 2, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the compilation error related to the specialization of std::hash for gsl::not_null<std::shared_ptr> by changing the template deduction from decltype(.get()) to use typename T::element_type.

  • Update not_null_hash template in include/gsl/pointers to correctly deduce the type.
  • Add new tests in tests/notnull_tests.cpp to verify correct behavior of std::hash with not_null.
  • Ensure compatibility with both C++14 and C++20 standards.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/notnull_tests.cpp Added test cases to validate correct hashing behavior for not_null<std::shared_ptr>.
include/gsl/pointers Updated the not_null_hash template to use typename T::element_type for proper type deduction.

@carsonRadtke
Carson Radtke (carsonRadtke) marked this pull request as ready for review June 3, 2025 14:35
Comment thread include/gsl/pointers
@carsonRadtke

Copy link
Copy Markdown
Member

Copilot Can you rebase these changes onto main so the tests actions re-run?

Copilot AI commented Dec 4, 2025

Copy link
Copy Markdown
Contributor Author

Copilot Can you rebase these changes onto main so the tests actions re-run?

Rebased the changes onto main in commit 9371256. The CI test actions should now re-run on the updated codebase.

Comment thread docs/upgrade_checklist.md
Copilot AI and others added 5 commits December 5, 2025 08:46
Co-authored-by: carsonRadtke <10507970+carsonRadtke@users.noreply.github.com>
…null_hash

Co-authored-by: carsonRadtke <10507970+carsonRadtke@users.noreply.github.com>
Co-authored-by: carsonRadtke <10507970+carsonRadtke@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread include/gsl/pointers
Comment thread tests/notnull_tests.cpp
@carsonRadtke
Carson Radtke (carsonRadtke) merged commit 1883887 into main Dec 5, 2025
96 checks passed
@carsonRadtke
Carson Radtke (carsonRadtke) deleted the copilot/fix-1209 branch December 8, 2025 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Review Needed Needs review from GSL maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compilation error with std::hash<gsl::not_null<std::shared_ptr<T>>> in GSL 4.2.0

4 participants