Skip to content

Refactor smt_function_application_termt::indices using C++17 feature #8035

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 6 additions & 19 deletions src/solvers/smt2_incremental/ast/smt_terms.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,28 +153,15 @@ class smt_function_application_termt : public smt_termt
{
};

/// Overload for when \p functiont does not have indices.
template <class functiont>
static std::vector<smt_indext>
indices(const functiont &function, const std::false_type &has_indices)
{
return {};
}

/// Overload for when \p functiont has indices member function.
template <class functiont>
static std::vector<smt_indext>
indices(const functiont &function, const std::true_type &has_indices)
{
return function.indices();
}

/// Returns `function.indices` if `functiont` has an `indices` member function
/// or returns an empty collection otherwise.
/// Returns `function.indices()` if `functiont` has an `indices` member
/// function or returns an empty collection otherwise.
template <class functiont>
static std::vector<smt_indext> indices(const functiont &function)
{
return indices(function, has_indicest<functiont>{});
if constexpr(has_indicest<functiont>::value)
return function.indices();
else
return {};
Comment on lines +161 to +164
Copy link
Contributor

Choose a reason for hiding this comment

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

That's the change that I wanted to do had I the time for it 🥇

}

public:
Expand Down