Skip to content
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

Fix visiblity for linux: move explicit instanciations to the header file #565

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
11 changes: 11 additions & 0 deletions include/gz/math/MovingWindowFilter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ namespace gz
using MovingWindowFilterVector3f = MovingWindowFilter<Vector3f>;
using MovingWindowFilterVector3d = MovingWindowFilter<Vector3d>;
}


/// The template explicit instantiations that does not use fundamental types
/// (like Vector*) needs to be placed in this header file.
template class GZ_MATH_VISIBLE MovingWindowFilter<int>;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if putting explicit instantiations in a header is the right thing to do (see https://stackoverflow.com/questions/5864401/does-explicit-template-instantiation-go-in-cpp-or-header-file). If every user of this header instantiates these classes, we'd have ODR issues. Also, we'd lose the benefit of explicit instantiation since every translation unit will be instantiating the templates.

template class GZ_MATH_VISIBLE MovingWindowFilter<float>;
template class GZ_MATH_VISIBLE MovingWindowFilter<double>;
template class GZ_MATH_VISIBLE MovingWindowFilter<gz::math::Vector3i>;
template class GZ_MATH_VISIBLE MovingWindowFilter<gz::math::Vector3f>;
template class GZ_MATH_VISIBLE MovingWindowFilter<gz::math::Vector3d>;

} // namespace math
} // namespace gz
#endif
7 changes: 0 additions & 7 deletions src/MovingWindowFilter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,6 @@ MovingWindowFilter<gz::math::Vector3d>::Value() const
return value;
}

template class MovingWindowFilter<int>;
template class MovingWindowFilter<float>;
template class MovingWindowFilter<double>;
template class MovingWindowFilter<gz::math::Vector3i>;
template class MovingWindowFilter<gz::math::Vector3f>;
template class MovingWindowFilter<gz::math::Vector3d>;

}
} // namespace math
} // namespace gz