boost

De-Serializing an STL map class member

佐手、 提交于 2021-02-09 11:37:47
问题 I am new to boost & boost serialization. I am trying to de-serialize a STL map class member. Here is the code : ... class Face { friend std::ostream & operator<<(std::ostream &os, const Face &mf); friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int /* file_version */){ ar & mFaceID; } public: size_t mFaceID; /*!< an integer value represents the Face Identification number */ void setFaceId(const size_t& faceID) { mFaceID = faceID;

boost::any_range with optimization level -O2 causes crash

谁说胖子不能爱 提交于 2021-02-09 11:33:56
问题 What is the problem with this code: #include <iostream> #include <vector> #include <boost/range/adaptor/transformed.hpp> #include <boost/range/any_range.hpp> using namespace boost::adaptors; using Range = boost::any_range< int, boost::forward_traversal_tag, int, std::ptrdiff_t>; void magic(const Range &) {} int main() { std::vector<int> xs{0, 1, 2}; auto ys = xs | transformed([](auto x) { return x; }); const Range zs = ys; std::vector<int> us{boost::begin(zs), boost::end(zs)}; magic(us);

boost::any_range with optimization level -O2 causes crash

时光毁灭记忆、已成空白 提交于 2021-02-09 11:32:49
问题 What is the problem with this code: #include <iostream> #include <vector> #include <boost/range/adaptor/transformed.hpp> #include <boost/range/any_range.hpp> using namespace boost::adaptors; using Range = boost::any_range< int, boost::forward_traversal_tag, int, std::ptrdiff_t>; void magic(const Range &) {} int main() { std::vector<int> xs{0, 1, 2}; auto ys = xs | transformed([](auto x) { return x; }); const Range zs = ys; std::vector<int> us{boost::begin(zs), boost::end(zs)}; magic(us);

boost::any_range with optimization level -O2 causes crash

旧巷老猫 提交于 2021-02-09 11:32:41
问题 What is the problem with this code: #include <iostream> #include <vector> #include <boost/range/adaptor/transformed.hpp> #include <boost/range/any_range.hpp> using namespace boost::adaptors; using Range = boost::any_range< int, boost::forward_traversal_tag, int, std::ptrdiff_t>; void magic(const Range &) {} int main() { std::vector<int> xs{0, 1, 2}; auto ys = xs | transformed([](auto x) { return x; }); const Range zs = ys; std::vector<int> us{boost::begin(zs), boost::end(zs)}; magic(us);

How to define (non-method) functions in header libraries

我的未来我决定 提交于 2021-02-09 02:51:18
问题 When writing a header library (like Boost), can one define free-floating (non-method) functions without (1) bloating the generated binary and (2) incurring "unused" warnings? When I define a function in a header that's included by multiple source files which in turn is linked into the same binary, the linker complains about redefinitions. One way around this is to make the functions static, but this reproduces the code in each translation unit (BTW, can linkers safely dereplicate these?).

How to define (non-method) functions in header libraries

放肆的年华 提交于 2021-02-09 02:47:12
问题 When writing a header library (like Boost), can one define free-floating (non-method) functions without (1) bloating the generated binary and (2) incurring "unused" warnings? When I define a function in a header that's included by multiple source files which in turn is linked into the same binary, the linker complains about redefinitions. One way around this is to make the functions static, but this reproduces the code in each translation unit (BTW, can linkers safely dereplicate these?).

How to define (non-method) functions in header libraries

岁酱吖の 提交于 2021-02-09 02:46:19
问题 When writing a header library (like Boost), can one define free-floating (non-method) functions without (1) bloating the generated binary and (2) incurring "unused" warnings? When I define a function in a header that's included by multiple source files which in turn is linked into the same binary, the linker complains about redefinitions. One way around this is to make the functions static, but this reproduces the code in each translation unit (BTW, can linkers safely dereplicate these?).

Replacing boost with std implementation

南楼画角 提交于 2021-02-09 02:46:13
问题 What is the correct way to replace this: std::ostringstream buf; std::for_each(bd.begin(), bd.end(), buf << boost::lambda::constant(" ") << boost::lambda::_1); With an implementation that doesn't use boost? This is what I've tried: std::string backspace("&nbps;"); std::ostringstream buf; std::for_each(bd.begin(), bd.end(), buf << backspace << std::placeholders::_1); The second '<<' is underlined in red and I get the error message: error C2679: binary '<<' : no operator found which takes a

C++ how to set a fixed decimal precision for a float

吃可爱长大的小学妹 提交于 2021-02-08 23:41:45
问题 I have an API call which returns a double. The double's decimal length can variate from many decimal places to a few (it all comes down to the state of an actuator). This double represents the current position on the range radius of an actuator. I am not interested in such a detailed number, because it adds alot of noise to the system. I've been using floats to save space, but still I have floats which have 6-8 decimal length. I am not interested in floor or ceil, simply because it doesn't do

C++ how to set a fixed decimal precision for a float

久未见 提交于 2021-02-08 23:41:05
问题 I have an API call which returns a double. The double's decimal length can variate from many decimal places to a few (it all comes down to the state of an actuator). This double represents the current position on the range radius of an actuator. I am not interested in such a detailed number, because it adds alot of noise to the system. I've been using floats to save space, but still I have floats which have 6-8 decimal length. I am not interested in floor or ceil, simply because it doesn't do