diff --git a/local/pkgs/biu/include/biu/eigen.hpp b/local/pkgs/biu/include/biu/eigen.hpp index b0ea6201..a648bce7 100644 --- a/local/pkgs/biu/include/biu/eigen.hpp +++ b/local/pkgs/biu/include/biu/eigen.hpp @@ -6,46 +6,49 @@ namespace biu { - namespace detail_ + namespace detail_::eigen { + // user-specified size of destination container: dynamic, unspecified(use default), or fixed constexpr std::size_t dynamicSize = std::dynamic_extent, unspecifiedSize = std::dynamic_extent - 1; - template struct ToEigenHelper {}; - template struct FromEigenHelper {}; + static_assert(std::dynamic_extent == std::numeric_limits::max()); + + // supported types of standard containers + template struct SpecializationOfArrayHelper : std::false_type {}; + template + struct SpecializationOfArrayHelper, Scalar> : std::true_type {}; + template + struct SpecializationOfArrayHelper, void> : std::true_type {}; + template concept SpecializationOfArray = + SpecializationOfArrayHelper::value; + template concept StandardContainer = + SpecializationOf || SpecializationOfArray; + + // helper operator| to specify the size of the destination container + // usage: some_value | toEigen + template struct ToEigenHelper {}; + template + inline constexpr ToEigenHelper toEigen; + // convert 1D standard container to Eigen::Vector + // if no size is specified, convert std::vector to dynamic-size Eigen::Vector, + // std::array to fixed-size Eigen::Vector; + // if size is std::dynamic_extent, always convert to dynamic-size Eigen::Vector + // if size is specified as a number, convert to fixed-size Eigen::Vector if specified size equals the size of the + // input, otherwise throw an error + template