C++中的boost库中的function_types::is_function_reference的测试程序

159 篇文章 ¥59.90 ¥99.00
本文介绍了一个C++编程示例,展示了如何利用Boost库中的function_types::is_function_reference模板检测函数类型是否为函数引用。通过定义函数引用、函数指针和普通函数类型,演示了该模板的用法及其在类型检测中的应用。

C++中的boost库中的function_types::is_function_reference的测试程序

在C++编程中,Boost库提供了许多有用的功能和工具,用于增强C++语言的能力。其中之一是function_types命名空间,它提供了一组工具,用于检测函数类型的属性和特征。其中的is_function_reference模板是用于检测给定类型是否为函数引用类型的工具。

下面是一个简单的示例程序,展示了如何使用boost::function_types::is_function_reference模板进行类型检测:

#include <iostream>
#include <boost/function_types/is_function_reference.hpp>

// 定义一个函数引用类型
era/src/2lidar_camera_node.cpp:262:30: error: no match for ‘operator&&’ (operand types are ‘bool’ and ‘sensor_msgs::msg::PointCloud2’ {aka ‘sensor_msgs::msg::PointCloud2_<std::allocator<void> >’}) 262 | if (rgb_msg && image_msg && cloud_msg) { | ~~~~~~~~~~~~~~~~~~~~ ^~ ~~~~~~~~~ | | | | bool sensor_msgs::msg::PointCloud2 {aka sensor_msgs::msg::PointCloud2_<std::allocator<void> >} /home/xingchen/gongzuo/2lidar_camera/calibrat_lidarcamera/ros2_ws/src/2lidar_camera/src/2lidar_camera_node.cpp:262:30: note: candidate: ‘operator&&(bool, bool)’ (built-in) 262 | if (rgb_msg && image_msg && cloud_msg) { | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~ /home/xingchen/gongzuo/2lidar_camera/calibrat_lidarcamera/ros2_ws/src/2lidar_camera/src/2lidar_camera_node.cpp:262:30: note: no known conversion for argument 2 from ‘sensor_msgs::msg::PointCloud2’ {aka ‘sensor_msgs::msg::PointCloud2_<std::allocator<void> >’} to ‘bool’ /home/xingchen/gongzuo/2lidar_camera/calibrat_lidarcamera/ros2_ws/src/2lidar_camera/src/2lidar_camera_node.cpp:333:29: error: ‘make_shared’ is not a member of ‘boost’ 333 | auto cloud_ptr = boost::make_shared<PointCloudT>(cloud2); | ^~~~~~~~~~~ /home/xingchen/gongzuo/2lidar_camera/calibrat_lidarcamera/ros2_ws/src/2lidar_camera/src/2lidar_camera_node.cpp:333:29: note: suggested alternatives: In file included from /usr/include/c++/11/memory:77, from /opt/ros/humble/include/rclcpp/rclcpp/rclcpp.hpp:153, from /home/xingchen/gongzuo/2lidar_camera/calibrat_lidarcamera/ros2_ws/src/2lidar_camera/src/2lidar_camera_node.cpp:1: /usr/include/c++/11/bits/shared_ptr.h:875:5: note: ‘std::make_shared’ 875 | make_shared(_Args&&... __args) | ^~~~~~~~~~~ In file included from /usr/include/pcl-1.12/pcl/io/pcd_io.h:42, from /home/xingchen/gongzuo/2lidar_camera/calibrat_lidarcamera/ros2_ws/src/2lidar_camera/include/lidar_camera/transforms.h:1, from /home/xingchen/gongzuo/2lidar_camera/calibrat_lidarcamera/ros2_ws/src/2lidar_camera/src/2lidar_camera_node.cpp:10: /usr/include/pcl-1.12/pcl/memory.h:122:66: note: ‘pcl::make_shared’ 122 | enable_if_t<!has_custom_allocator<T>::value, shared_ptr<T>> make_shared(Args&&... args) | ^~~~~~~~~~~ /home/xingchen/gongzuo/2lidar_camera/calibrat_lidarcamera/ros2_ws/src/2lidar_camera/src/2lidar_camera_node.cpp:333:52: error: expected primary-expression before ‘>’ token 333 | auto cloud_ptr = boost::make_shared<PointCloudT>(cloud2); | ^ /home/xingchen/gongzuo/2lidar_camera/calibrat_lidarcamera/ros2_ws/src/2lidar_camera/src/2lidar_camera_node.cpp:344:18: error: cannot bind non-const lvalue reference of type ‘Eigen::Vector3f&’ {aka ‘Eigen::Matrix<float, 3, 1>&’} to an rvalue of type ‘Eigen::Vector3f’ {aka ‘Eigen::Matrix<float, 3, 1>’} 344 | ensureNormal(n1, n2);
08-20
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值