Conversation
1b5cd5d to
f2de5f4
Compare
4be254b to
c8f8c17
Compare
| return std::hash<T>()(::std::any_cast<T>(id)); | ||
| size_t Hash(const std::any& id) const override { | ||
| return std::hash<T>()(std::any_cast<T>(id)); |
There was a problem hiding this comment.
Inconsistent error handling: try-catch blocks were added to Has and CompareIdsLess methods but not to Hash and CompareIdsEqual methods, which also use std::any_cast and could throw exceptions.
Recommendation: Add similar try-catch blocks to the Hash method:
size_t Hash(const std::any& id) const override {
try {
return std::hash<T>()(std::any_cast<T>(id));
} catch (const std::bad_any_cast&) {
// Handle the error
return 0; // Return a default hash value
}
}| } | ||
| } | ||
|
|
||
| bool CompareIdsEqual(const ::std::any& a, const ::std::any& b) const override { |
There was a problem hiding this comment.
Inconsistent error handling: try-catch blocks were added to Has and CompareIdsLess methods but not to CompareIdsEqual method, which also uses std::any_cast and could throw exceptions.
Recommendation: Add similar try-catch blocks to the CompareIdsEqual method:
bool CompareIdsEqual(const std::any& a, const std::any& b) const override {
try {
auto& ca = std::any_cast<const T&>(a);
auto& cb = std::any_cast<const T&>(b);
return ca == cb;
} catch (const std::bad_any_cast&) {
// Handle the error
return false; // Return a default value
}
}| IMPLEMENT | ||
| return varIds.find(::std::any_cast<T>(id)) != varIds.end(); | ||
| bool Has(const std::any& id) const override { | ||
| try { |
There was a problem hiding this comment.
Inconsistent namespace usage throughout the file. The PR changes some instances from ::std::any_cast to std::any_cast but not all of them. This creates inconsistency in the codebase.
Recommendation: Standardize on either std::any_cast or ::std::any_cast throughout the file for better readability and maintainability. Since the PR is moving toward using std::any_cast without the leading colons, consider updating all instances to follow this pattern.
951918b to
38208a4
Compare
64cda3d to
ed3dc93
Compare
| return std::any_cast<T>(a) < std::any_cast<T>(b); | ||
| } catch (const std::bad_any_cast&) { | ||
| // Handle the error, e.g., log it or return a default value | ||
| // For now, we'll return false to indicate the comparison failed |
There was a problem hiding this comment.
Inconsistent error handling across methods: try-catch blocks were added to Has and CompareIdsLess methods but not to Hash and CompareIdsEqual methods, which also use std::any_cast and could throw exceptions.
Recommendation: Add similar try-catch blocks to the Hash method:
size_t Hash(const std::any& id) const override {
try {
return std::hash<T>()(std::any_cast<T>(id));
} catch (const std::bad_any_cast&) {
// Handle the error
return 0; // Return a default hash value
}
}And to the CompareIdsEqual method:
bool CompareIdsEqual(const std::any& a, const std::any& b) const override {
try {
auto& ca = std::any_cast<const T&>(a);
auto& cb = std::any_cast<const T&>(b);
return ca == cb;
} catch (const std::bad_any_cast&) {
// Handle the error
return false; // Return a default value
}
}|
|
||
| bool CompareIdsLess(const std::any& a, const std::any& b) const override { | ||
| try { | ||
| return std::any_cast<T>(a) < std::any_cast<T>(b); |
There was a problem hiding this comment.
Inconsistent namespace usage throughout the file. The PR changes some instances from ::std::any_cast to std::any_cast but not all of them. This creates inconsistency in the codebase.
Recommendation: Standardize on either std::any_cast or ::std::any_cast throughout the file for better readability and maintainability. Since the PR is moving toward using std::any_cast without the leading colons, consider updating all instances to follow this pattern, including in the CompareIdsEqual method and other locations in the file.
| // For now, we'll return false to indicate the id was not found | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| size_t Hash(const ::std::any& id) const override { | ||
| return std::hash<T>()(::std::any_cast<T>(id)); | ||
| size_t Hash(const std::any& id) const override { | ||
| return std::hash<T>()(std::any_cast<T>(id)); | ||
| } | ||
|
|
||
| bool CompareIdsLess(const ::std::any& a, const ::std::any& b) const override { | ||
| return ::std::any_cast<T>(a) < ::std::any_cast<T>(b); | ||
|
|
||
| bool CompareIdsLess(const std::any& a, const std::any& b) const override { | ||
| try { | ||
| return std::any_cast<T>(a) < std::any_cast<T>(b); | ||
| } catch (const std::bad_any_cast&) { |
There was a problem hiding this comment.
Inconsistent error handling across methods: try-catch blocks were added to Has and CompareIdsLess methods but not to Hash and CompareIdsEqual methods, which also use std::any_cast and could throw exceptions.
Recommendation: Add similar try-catch blocks to the Hash method:
size_t Hash(const std::any& id) const override {
try {
return std::hash<T>()(std::any_cast<T>(id));
} catch (const std::bad_any_cast&) {
// Handle the error
return 0; // Return a default hash value
}
}And to the CompareIdsEqual method:
bool CompareIdsEqual(const std::any& a, const std::any& b) const override {
try {
auto& ca = std::any_cast<const T&>(a);
auto& cb = std::any_cast<const T&>(b);
return ca == cb;
} catch (const std::bad_any_cast&) {
// Handle the error
return false; // Return a default value
}
}|
|
||
| bool CompareIdsLess(const std::any& a, const std::any& b) const override { | ||
| try { | ||
| return std::any_cast<T>(a) < std::any_cast<T>(b); | ||
| } catch (const std::bad_any_cast&) { |
There was a problem hiding this comment.
Inconsistent namespace usage throughout the file. The PR changes some instances from ::std::any_cast to std::any_cast but not all of them. This creates inconsistency in the codebase.
Recommendation: Standardize on either std::any_cast or ::std::any_cast throughout the file for better readability and maintainability. Since the PR is moving toward using std::any_cast without the leading colons, consider updating all instances to follow this pattern, including in the CompareIdsEqual method and other locations in the file.
9118bee to
352a2de
Compare
| // For now, we'll return false to indicate the id was not found | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| size_t Hash(const ::std::any& id) const override { | ||
| return std::hash<T>()(::std::any_cast<T>(id)); | ||
| size_t Hash(const std::any& id) const override { | ||
| return std::hash<T>()(std::any_cast<T>(id)); | ||
| } | ||
|
|
||
| bool CompareIdsLess(const ::std::any& a, const ::std::any& b) const override { | ||
| return ::std::any_cast<T>(a) < ::std::any_cast<T>(b); | ||
|
|
||
| bool CompareIdsLess(const std::any& a, const std::any& b) const override { | ||
| try { | ||
| return std::any_cast<T>(a) < std::any_cast<T>(b); | ||
| } catch (const std::bad_any_cast&) { |
There was a problem hiding this comment.
Inconsistent error handling across methods: try-catch blocks were added to Has and CompareIdsLess methods but not to Hash and CompareIdsEqual methods, which also use std::any_cast and could throw exceptions.
Recommendation: Add similar try-catch blocks to the Hash method:
size_t Hash(const std::any& id) const override {
try {
return std::hash<T>()(std::any_cast<T>(id));
} catch (const std::bad_any_cast&) {
// Handle the error
return 0; // Return a default hash value
}
}And to the CompareIdsEqual method:
bool CompareIdsEqual(const std::any& a, const std::any& b) const override {
try {
auto& ca = std::any_cast<const T&>(a);
auto& cb = std::any_cast<const T&>(b);
return ca == cb;
} catch (const std::bad_any_cast&) {
// Handle the error
return false; // Return a default value
}
}| bool Has(const std::any& id) const override { | ||
| try { | ||
| return varIds.find(std::any_cast<T>(id)) != varIds.end(); | ||
| } catch (const std::bad_any_cast&) { | ||
| // Handle the error, e.g., log it or return a default value | ||
| // For now, we'll return false to indicate the id was not found | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| size_t Hash(const ::std::any& id) const override { | ||
| return std::hash<T>()(::std::any_cast<T>(id)); | ||
| size_t Hash(const std::any& id) const override { | ||
| return std::hash<T>()(std::any_cast<T>(id)); | ||
| } | ||
|
|
||
| bool CompareIdsLess(const ::std::any& a, const ::std::any& b) const override { | ||
| return ::std::any_cast<T>(a) < ::std::any_cast<T>(b); | ||
|
|
||
| bool CompareIdsLess(const std::any& a, const std::any& b) const override { | ||
| try { | ||
| return std::any_cast<T>(a) < std::any_cast<T>(b); | ||
| } catch (const std::bad_any_cast&) { |
There was a problem hiding this comment.
Inconsistent namespace usage throughout the file. The PR changes some instances from ::std::any_cast to std::any_cast but not all of them. This creates inconsistency in the codebase.
Recommendation: Standardize on either std::any_cast or ::std::any_cast throughout the file for better readability and maintainability. Since the PR is moving toward using std::any_cast without the leading colons, consider updating all instances to follow this pattern, including in the CompareIdsEqual method and other locations in the file.
|
I've reviewed the changes in PR #296 and found two issues that should be addressed:
|
| return std::hash<T>()(::std::any_cast<T>(id)); | ||
| size_t Hash(const std::any& id) const override { | ||
| return std::hash<T>()(std::any_cast<T>(id)); |
There was a problem hiding this comment.
Inconsistent error handling across methods
The PR adds try-catch blocks to Has and CompareIdsLess methods but not to Hash and CompareIdsEqual methods, which also use std::any_cast and could throw exceptions.
Recommendation for Hash method:
size_t Hash(const std::any& id) const override {
try {
return std::hash<T>()(std::any_cast<T>(id));
} catch (const std::bad_any_cast&) {
// Handle the error
return 0; // Return a default hash value
}
}And for CompareIdsEqual method:
bool CompareIdsEqual(const std::any& a, const std::any& b) const override {
try {
auto& ca = std::any_cast<const T&>(a);
auto& cb = std::any_cast<const T&>(b);
return ca == cb;
} catch (const std::bad_any_cast&) {
// Handle the error
return false; // Return a default value
}
}| } | ||
| } | ||
|
|
||
| bool CompareIdsEqual(const ::std::any& a, const ::std::any& b) const override { |
There was a problem hiding this comment.
Inconsistent namespace usage
The PR changes some instances from ::std::any_cast to std::any_cast but not all of them, creating inconsistency in the codebase.
For example, in CompareIdsEqual method, it still uses ::std::any_cast while other methods have been updated to use std::any_cast.
Recommendation: Standardize on either std::any_cast or ::std::any_cast throughout the file for better readability and maintainability. Since the PR is moving toward using std::any_cast without the leading colons, consider updating all instances to follow this pattern.
d065eb7 to
8ba3493
Compare
|
Inconsistent error handling across methods The PR adds try-catch blocks to Recommendation for size_t Hash(const std::any& id) const override {
try {
return std::hash<T>()(std::any_cast<T>(id));
} catch (const std::bad_any_cast&) {
// Handle the error
return 0; // Return a default hash value
}
}And for bool CompareIdsEqual(const std::any& a, const std::any& b) const override {
try {
auto& ca = std::any_cast<const T&>(a);
auto& cb = std::any_cast<const T&>(b);
return ca == cb;
} catch (const std::bad_any_cast&) {
// Handle the error
return false; // Return a default value
}
} |
|
Inconsistent namespace usage The PR changes some instances from For example, in Recommendation: Standardize on either |
|
I've completed my review of PR #296 and identified two issues that should be addressed:
Please see my detailed comments above for specific recommendations on how to address these issues. |
No description provided.