boost

C++ add 1 year to date

孤人 提交于 2020-03-21 03:47:02
问题 This is how im generating my date i want to add 1 year to it. Thanks in advance. char tmpbuf[128]; time_t ltime; struct tm *today; stringstream reD; string todayDate; time( &ltime ); today = localtime( &ltime ); strftime( tmpbuf, 128,"%Y-%m-%d_%H:%M:%S", today ); reD << tmpbuf; reD >> todayDate; boost::replace_all(todayDate, "_", " "); cout << todayDate << endl; OK ive decided to go with boost since it will be easier to add days, so 2 examples i need one to add 1 year, and one to add 14 days,

How to solve the issue of “read of non-constexpr variable 'a' is not allowed in a constant expression” with boost.hana

旧巷老猫 提交于 2020-03-18 11:44:28
问题 I'm using c++17 with Boost.hana to write some meta-programming programs. One issue stuck me is what kind of expression can be used in a constexpr context like static_assert. Here is an example: #include <boost/hana.hpp> using namespace boost::hana::literals; template <typename T> class X { public: T data; constexpr explicit X(T x) : data(x) {} constexpr T getData() { return data; } }; int main() { { // test1 auto x1 = X(1_c); static_assert(x1.data == 1_c); static_assert(x1.getData() == 1_c);

Cmake doesn't find Boost

╄→гoц情女王★ 提交于 2020-03-07 04:33:10
问题 I'm trying to configure a project using CMake, but it fails to find Boost libraries even though they are in the specified folder. I have specified Boost_INCLUDE_DIR , Boost_LIBRARYDIR and BOOST_ROOT , but I still get an error saying that CMake is not able to find Boost. What could be the reason of such error? 回答1: Are you sure you are doing it the correct way? The idea is that CMake sets BOOST_INCLUDE_DIR , BOOST_LIBRARYDIR and BOOST_ROOT automatically. Do something like this in CMakeLists

boost::asio acceptor reopen and async read after EOF

吃可爱长大的小学妹 提交于 2020-03-06 03:55:27
问题 sadly I've come to a hold in my development since I can not understand how exactly the boost::asio::ip::tcp::acceptor is supposed to be used. The TCPReader class is designed to be a singleton and the header declares the following as private. void runInThread(); void read_handler(const boost::system::error_code &ec, std::size_t bytes_transferred); void accept_handler(const boost::system::error_code &ec); boost::asio::io_service io_service; boost::asio::io_service::work runningService; boost:

How to implement Boost::Serialize for Boost::Nested_Container

匆匆过客 提交于 2020-03-05 06:04:29
问题 (Followup of another question.) Boost::Serialize often delivers an exception on oarchive, complaining that re-creating a particular object would result in duplicate objects. Some archives save and re-load successfully, but many result in the error above. I have not been able yet to determine the exact conditions under which the error occurs, but I have proven that none of the content used to populate the nested_container and the flat object list contains duplicate object IDs. I am using text

looking for a MemoryStream in C++

北慕城南 提交于 2020-03-01 23:13:58
问题 In the wonderful world of C# i can create a memory stream without specifying its size, write into it and then just take the underlying buffer. How can i do the same in c++? basicly i need to do: memory_stream ms(GROW_AS_MUCH_AS_YOU_LIKE); ms << someLargeObjects << someSmallObjects << someObjectsWhosSizeIDontKnow; unsigned char* buffer = ms.GetBuffer(); int bufferSize = ms.GetBufferSize(); rawNetworkSocket.Send(buffer, bufferSize); By the way I have boost in my project though I'm not all that

DDE using boost odeint

孤者浪人 提交于 2020-02-28 08:30:52
问题 Is it possible to solve a time delay differential equations using C++ Boost - odeint library ? For an instance below equation: x'(t) = r*x(t)*(1 - x(t-tau)), where tau is a constant value for time delay. 回答1: Yes, you can. But odeint is not explicitly designed for DDEs. There are two possibilities to solve DDEs with odeint: You consider x and its discretized history as dependend variables and use directly the steppers. You consider only x as dependent variable and pass the history with the

Boost.Asio without Boost.System

為{幸葍}努か 提交于 2020-02-28 08:24:31
问题 On the Boost System page it is stated that: The Boost System Library is part of the C++11 Standard Library. But a number of Boost libraries, such as Asio, depend on Boost System. Is it possible to use the C++11 std stuff instead of Boost System to work with Asio? 回答1: AFAIR you can configure Boost System to be header-only Source: http://www.boost.org/doc/libs/1_66_0/libs/system/doc/reference.html Other than that, you might simply use Non-Boost Asio 来源: https://stackoverflow.com/questions

Android: error: use of undeclared identifier 'fseeko'

北慕城南 提交于 2020-02-25 04:00:38
问题 When I am trying to build a boost library in Android using its source code, I am getting below error release|armeabi-v7a : D:/Android/Sdk/ndk->bundle/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1\fstream:969:9: release|armeabi-v7a : error: use of undeclared identifier 'fseeko' release|armeabi-v7a : if (fseeko(__file_, __sp, SEEK_SET)) Below is my CMake externalNativeBuild { cmake { cppFlags "-std=c++14 -frtti -fexceptions -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"

Android: error: use of undeclared identifier 'fseeko'

北战南征 提交于 2020-02-25 04:00:33
问题 When I am trying to build a boost library in Android using its source code, I am getting below error release|armeabi-v7a : D:/Android/Sdk/ndk->bundle/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1\fstream:969:9: release|armeabi-v7a : error: use of undeclared identifier 'fseeko' release|armeabi-v7a : if (fseeko(__file_, __sp, SEEK_SET)) Below is my CMake externalNativeBuild { cmake { cppFlags "-std=c++14 -frtti -fexceptions -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"