Skip to content

Commit

Permalink
Remove explicit template instantiations (#32)
Browse files Browse the repository at this point in the history
I know of no reason why explicit template instantiations should ever
appear in a header file: code that includes the header file will
already implicitly instantiate any templates that it uses. The effect
of the instantiations is only to copy unnecessary object code into
every translation unit that calls this library.

In any case, for trivial wrapper structs it's always better to use
function inlining anyway; for performance, we don't actually want to
be jumping through extern functions when dealing with these wrappers.
  • Loading branch information
jwnimmer-tri authored Feb 27, 2024
1 parent 58e9f38 commit 17ce4cd
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 12 deletions.
4 changes: 0 additions & 4 deletions include/cpp/DefaultInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,4 @@ struct DefaultInfo
clarabel::SolverStatus status;
};

// Instantiate the templates
template struct DefaultInfo<double>;
template struct DefaultInfo<float>;

} // namespace clarabel
4 changes: 0 additions & 4 deletions include/cpp/DefaultSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ struct DefaultSettings
static DefaultSettings<T> default_settings();
};

// Instantiate the templates
template struct DefaultSettings<double>;
template struct DefaultSettings<float>;

template<typename T = double>
class DefaultSettingsBuilder
{
Expand Down
4 changes: 0 additions & 4 deletions include/cpp/DefaultSolution.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,4 @@ class DefaultSolution
}
};

// Instantiate the templates
template struct DefaultSolution<double>;
template struct DefaultSolution<float>;

} // namespace clarabel

0 comments on commit 17ce4cd

Please sign in to comment.