Skip to content

Commit f0a290e

Browse files
committed
Use if constexpr in smt_function_application_termt::indices
With C++17's `if constexpr` feature we can now remove two alternate function templates and just put the alternate implementations in line. This puts the specialisation into the outer function, so that it is specialised with the correct implementation for the given `functiont`, rather than dispatching based on the `std::true_type` / `std::false_type` overloads.
1 parent 3db3e49 commit f0a290e

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

src/solvers/smt2_incremental/ast/smt_terms.h

+6-19
Original file line numberDiff line numberDiff line change
@@ -153,28 +153,15 @@ class smt_function_application_termt : public smt_termt
153153
{
154154
};
155155

156-
/// Overload for when \p functiont does not have indices.
157-
template <class functiont>
158-
static std::vector<smt_indext>
159-
indices(const functiont &function, const std::false_type &has_indices)
160-
{
161-
return {};
162-
}
163-
164-
/// Overload for when \p functiont has indices member function.
165-
template <class functiont>
166-
static std::vector<smt_indext>
167-
indices(const functiont &function, const std::true_type &has_indices)
168-
{
169-
return function.indices();
170-
}
171-
172-
/// Returns `function.indices` if `functiont` has an `indices` member function
173-
/// or returns an empty collection otherwise.
156+
/// Returns `function.indices()` if `functiont` has an `indices` member
157+
/// function or returns an empty collection otherwise.
174158
template <class functiont>
175159
static std::vector<smt_indext> indices(const functiont &function)
176160
{
177-
return indices(function, has_indicest<functiont>{});
161+
if constexpr(has_indicest<functiont>::value)
162+
return function.indices();
163+
else
164+
return {};
178165
}
179166

180167
public:

0 commit comments

Comments
 (0)