Skip to content

Commit

Permalink
Make concepts work in the boost path
Browse files Browse the repository at this point in the history
  • Loading branch information
dellaert committed Feb 6, 2023
1 parent c6dd2bb commit 61a30b0
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion gtsam/base/Group.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class IsGroup {
typedef typename traits<G>::group_flavor flavor_tag;
//typedef typename traits<G>::identity::value_type identity_value_type;

GTSAM_CONCEPT_USAGE(IsGroup) {
BOOST_CONCEPT_USAGE(IsGroup) {
static_assert(
(std::is_base_of<group_tag, structure_category_tag>::value),
"This type's structure_category trait does not assert it as a group (or derived)");
Expand Down
2 changes: 1 addition & 1 deletion gtsam/base/Lie.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class IsLieGroup: public IsGroup<T>, public IsManifold<T> {
typedef typename traits<T>::TangentVector TangentVector;
typedef typename traits<T>::ChartJacobian ChartJacobian;

GTSAM_CONCEPT_USAGE(IsLieGroup) {
BOOST_CONCEPT_USAGE(IsLieGroup) {
static_assert(
(std::is_base_of<lie_group_tag, structure_category_tag>::value),
"This type's trait does not assert it is a Lie group (or derived)");
Expand Down
4 changes: 2 additions & 2 deletions gtsam/base/Manifold.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct HasManifoldPrereqs {
Eigen::Matrix<double, dim, 1> v;
OptionalJacobian<dim, dim> Hp, Hq, Hv;

GTSAM_CONCEPT_USAGE(HasManifoldPrereqs) {
BOOST_CONCEPT_USAGE(HasManifoldPrereqs) {
v = p.localCoordinates(q);
q = p.retract(v);
}
Expand Down Expand Up @@ -139,7 +139,7 @@ class IsManifold {
typedef typename traits<T>::ManifoldType ManifoldType;
typedef typename traits<T>::TangentVector TangentVector;

GTSAM_CONCEPT_USAGE(IsManifold) {
BOOST_CONCEPT_USAGE(IsManifold) {
static_assert(
(std::is_base_of<manifold_tag, structure_category_tag>::value),
"This type's structure_category trait does not assert it as a manifold (or derived)");
Expand Down
4 changes: 2 additions & 2 deletions gtsam/base/Testable.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace gtsam {
bool r1,r2;
public:

GTSAM_CONCEPT_USAGE(IsTestable) {
BOOST_CONCEPT_USAGE(IsTestable) {
// check print function, with optional string
traits<T>::Print(t, std::string());
traits<T>::Print(t);
Expand Down Expand Up @@ -134,7 +134,7 @@ namespace gtsam {
template<typename T>
struct HasTestablePrereqs {

GTSAM_CONCEPT_USAGE(HasTestablePrereqs) {
BOOST_CONCEPT_USAGE(HasTestablePrereqs) {
t->print(str);
b = t->equals(*s,tol);
}
Expand Down
4 changes: 2 additions & 2 deletions gtsam/base/VectorSpace.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ struct HasVectorSpacePrereqs {
Class p, q;
Vector v;

GTSAM_CONCEPT_USAGE(HasVectorSpacePrereqs) {
BOOST_CONCEPT_USAGE(HasVectorSpacePrereqs) {
p = Class::Identity(); // identity
q = p + p; // addition
q = p - p; // subtraction
Expand Down Expand Up @@ -472,7 +472,7 @@ class IsVectorSpace: public IsLieGroup<T> {

typedef typename traits<T>::structure_category structure_category_tag;

GTSAM_CONCEPT_USAGE(IsVectorSpace) {
BOOST_CONCEPT_USAGE(IsVectorSpace) {
static_assert(
(std::is_base_of<vector_space_tag, structure_category_tag>::value),
"This type's trait does not assert it as a vector space (or derived)");
Expand Down
8 changes: 5 additions & 3 deletions gtsam/base/concepts.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@

#ifdef GTSAM_USE_BOOST_FEATURES
#include <boost/concept_check.hpp>
#define GTSAM_CONCEPT_USAGE(concept) BOOST_CONCEPT_USAGE((concept))
#include <boost/concept/assert.hpp>
#include <boost/concept/requires.hpp>
#include <boost/concept_check.hpp>
#define GTSAM_CONCEPT_ASSERT(concept) BOOST_CONCEPT_ASSERT((concept))
#define GTSAM_CONCEPT_ASSERT1(concept) BOOST_CONCEPT_ASSERT((concept))
#define GTSAM_CONCEPT_ASSERT2(concept) BOOST_CONCEPT_ASSERT((concept))
#define GTSAM_CONCEPT_ASSERT3(concept) BOOST_CONCEPT_ASSERT((concept))
#define GTSAM_CONCEPT_ASSERT4(concept) BOOST_CONCEPT_ASSERT((concept))
#define GTSAM_CONCEPT_REQUIRES(concept, return_type) BOOST_CONCEPT_REQUIRES((concept), (return_type))
#define GTSAM_CONCEPT_REQUIRES(concept, return_type) BOOST_CONCEPT_REQUIRES(((concept)), (return_type))
#else
// These do something sensible:
#define GTSAM_CONCEPT_USAGE(concept) void check##concept()
#define BOOST_CONCEPT_USAGE(concept) void check##concept()
// TODO(dellaert): would be nice if it was a single macro...
#define GTSAM_CONCEPT_ASSERT(concept) concept checkConcept [[maybe_unused]];
#define GTSAM_CONCEPT_ASSERT1(concept) concept checkConcept1 [[maybe_unused]];
Expand Down

0 comments on commit 61a30b0

Please sign in to comment.