Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

Replace _append_variant() with variant_cat_t #192

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
#include "trajopt/constraint/Constraint.h"
#include "trajopt/constraint/differential/DifferentialCentripetalAccelerationConstraint.h"
#include "trajopt/constraint/differential/DifferentialTangentialVelocityConstraint.h"
#include "trajopt/util/AppendVariant.h"
#include "trajopt/util/VariantCat.h"

namespace trajopt {

using DifferentialConstraint =
decltype(_append_variant(Constraint{}, AngularVelocityConstraint{},
DifferentialTangentialVelocityConstraint{},
DifferentialCentripetalAccelerationConstraint{}));
variant_cat_t<Constraint, AngularVelocityConstraint,
DifferentialTangentialVelocityConstraint,
DifferentialCentripetalAccelerationConstraint>;

} // namespace trajopt
8 changes: 4 additions & 4 deletions include/trajopt/constraint/holonomic/HolonomicConstraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
#include "trajopt/constraint/Constraint.h"
#include "trajopt/constraint/PointAtConstraint.h"
#include "trajopt/constraint/holonomic/HolonomicVelocityConstraint.h"
#include "trajopt/util/AppendVariant.h"
#include "trajopt/util/VariantCat.h"

namespace trajopt {

using HolonomicConstraint = decltype(_append_variant(
Constraint{}, AngularVelocityConstraint{}, HolonomicVelocityConstraint{},
PointAtConstraint{}));
using HolonomicConstraint =
variant_cat_t<Constraint, AngularVelocityConstraint,
HolonomicVelocityConstraint, PointAtConstraint>;

} // namespace trajopt
36 changes: 0 additions & 36 deletions include/trajopt/util/AppendVariant.h

This file was deleted.

32 changes: 32 additions & 0 deletions include/trajopt/util/VariantCat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) TrajoptLib contributors

#pragma once

#include <variant>

namespace trajopt {

namespace detail {

//! @cond Doxygen_Suppress

template <typename Variant, typename... Args>
struct variant_cat;

template <typename... Args0, typename... Args1>
struct variant_cat<std::variant<Args0...>, Args1...> {
using type = std::variant<Args0..., Args1...>;
};

//! @endcond

} // namespace detail

/**
* Defines a new variant type that appends the types Args... to the variant type
* Variant.
*/
template <typename Variant, typename... Args>
using variant_cat_t = typename detail::variant_cat<Variant, Args...>::type;

} // namespace trajopt
Loading