Update Boost example (#531)

* Update CMake and main to add another library and download FASTER.

* Apply style formatters

* Update README.md's boost example and add information on determining source archive location at GitHub.

* Update README.md

---------

Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>
This commit is contained in:
Scott B
2024-02-02 12:25:34 -06:00
committed by GitHub
parent 3c25130ffa
commit a8144f511d
3 changed files with 111 additions and 12 deletions

View File

@@ -13,9 +13,10 @@ include(../../cmake/CPM.cmake)
CPMAddPackage(
NAME Boost
VERSION 1.81.0
GITHUB_REPOSITORY "boostorg/boost"
GIT_TAG "boost-1.81.0"
VERSION 1.84.0
URL https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.xz
URL_HASH SHA256=2e64e5d79a738d0fa6fb546c6e5c2bd28f88d268a2a080546f74e5ff98f29d0e
OPTIONS "BOOST_ENABLE_CMAKE ON" "BOOST_INCLUDE_LIBRARIES container\\\;asio" # Note the escapes!
)
target_link_libraries(CPMExampleBoost PRIVATE Boost::asio)
target_link_libraries(CPMExampleBoost PRIVATE Boost::asio Boost::container)

View File

@@ -9,18 +9,26 @@
//
#include <boost/asio.hpp>
#include <boost/container/devector.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <iostream>
#include <string>
void print(const boost::system::error_code& /*e*/) { std::cout << "Hello, world!" << std::endl; }
boost::container::devector<std::string> strings;
void print(const boost::system::error_code& /*e*/) {
for (const auto& a : strings) std::cout << a;
}
int main() {
boost::asio::io_service io;
strings.push_back("Hello, world!\n");
boost::asio::deadline_timer t(io, boost::posix_time::seconds(1));
t.async_wait(&print);
io.run();
return 0;
}
}