简体   繁体   English

没有井号的C ++宏定义

[英]C++ macro definition without a pound sign

Here is a c++ header file I found somewhere else. 这是我在其他地方找到的C ++头文件。

#include "opencv\cv.h"
#include <boost/serialization/split_free.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>

BOOST_SERIALIZATION_SPLIT_FREE(cv::Mat)
namespace boost {
namespace serialization {

/** Serialization support for cv::Mat */
template <class Archive>
void save(Archive & ar, const ::cv::Mat& m, const unsigned int version)
{

    size_t elem_size = m.elemSize();
    size_t elem_type = m.type();

    ar & m.cols;
    ar & m.rows;
    ar & elem_size;
    ar & elem_type;

    const size_t data_size = m.cols * m.rows * elem_size;
    ar & boost::serialization::make_array(m.ptr(), data_size);
}

};
}

My question is: What does the following code mean? 我的问题是:以下代码是什么意思?

BOOST_SERIALIZATION_SPLIT_FREE(cv::Mat)

Is it a macro definition? 它是一个宏定义吗? Then where is the pound sign "#"? 那么英镑符号“#”在哪里?

In short words, it's a macro . 简而言之, 它是一个宏 BOOST_SERIALIZATION_SPLIT_FREE(my_class) is the macro, which is short for the following free serialize function template: BOOST_SERIALIZATION_SPLIT_FREE(my_class)是宏,它是以下免费序列化功能模板的缩写:

namespace boost { namespace serialization {
    template<class Archive>
    inline void serialize(
        Archive & ar,
        my_class & t,
        const unsigned int file_version
        ){
            split_free(ar, t, file_version); 
    }
}}

Also note that BOOST_SERIALIZATION_SPLIT_FREE must be used outside of any namespace. 还要注意,必须在任何名称空间之外使用BOOST_SERIALIZATION_SPLIT_FREE Check out here for further info. 此处查看更多信息。

宏,用于将序列化函数拆分为保存和加载函数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM