Skip to content

Commit

Permalink
Add template-specialization guards
Browse files Browse the repository at this point in the history
  • Loading branch information
XanthosXanthopoulos committed Dec 13, 2024
1 parent 67e73d7 commit f8455c4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
29 changes: 28 additions & 1 deletion libtiledbsoma/src/soma/soma_column.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,36 @@ SOMAColumn::core_current_domain_slot<std::string>(
if (current_domain.first == "" && (current_domain.second == "\x7f" ||
current_domain.second == "\xff")) {
return std::pair<std::string, std::string>("", "");
} else {
throw TileDBSOMAError(std::format(
"[SOMAColumn][core_current_domain_slot] unexpected current "
"domain returnd ({}, {})",
current_domain.first,
current_domain.second));
}
} catch (const std::exception& e) {
throw TileDBSOMAError(e.what());
}
}

template <>
std::pair<std::string, std::string>
SOMAColumn::core_current_domain_slot<std::string>(NDRectangle& ndrect) const {
try {
std::pair<std::string, std::string>
current_domain = std::any_cast<std::pair<std::string, std::string>>(
_core_current_domain_slot(ndrect));

return current_domain;
if (current_domain.first == "" && (current_domain.second == "\x7f" ||
current_domain.second == "\xff")) {
return std::pair<std::string, std::string>("", "");
} else {
throw TileDBSOMAError(std::format(
"[SOMAColumn][core_current_domain_slot] unexpected current "
"domain returnd ({}, {})",
current_domain.first,
current_domain.second));
}
} catch (const std::exception& e) {
throw TileDBSOMAError(e.what());
}
Expand Down
16 changes: 16 additions & 0 deletions libtiledbsoma/src/soma/soma_column.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,12 @@ class SOMAColumn {
*/
template <typename T>
std::pair<T, T> core_domain_slot() const {
if (std::is_same_v<T, std::string>) {
throw std::runtime_error(
"SOMAArray::soma_domain_slot: template-specialization "
"failure.");
}

try {
return std::any_cast<std::pair<T, T>>(_core_domain_slot());
} catch (const std::exception& e) {
Expand Down Expand Up @@ -457,6 +463,12 @@ class SOMAColumn {
template <typename T>
std::pair<T, T> core_current_domain_slot(
const SOMAContext& ctx, Array& array) const {
if (std::is_same_v<T, std::string>) {
throw std::runtime_error(
"SOMAArray::soma_domain_slot: template-specialization "
"failure.");
}

try {
return std::any_cast<std::pair<T, T>>(
_core_current_domain_slot(ctx, array));
Expand Down Expand Up @@ -534,5 +546,9 @@ std::pair<std::string, std::string>
SOMAColumn::core_current_domain_slot<std::string>(
const SOMAContext& ctx, Array& array) const;

template <>
std::pair<std::string, std::string>
SOMAColumn::core_current_domain_slot<std::string>(NDRectangle& ndrect) const;

} // namespace tiledbsoma
#endif

0 comments on commit f8455c4

Please sign in to comment.