diff --git a/example/tutorial3/tutorial3.cpp b/example/tutorial3/tutorial3.cpp index 25395ad..4800501 100644 --- a/example/tutorial3/tutorial3.cpp +++ b/example/tutorial3/tutorial3.cpp @@ -42,8 +42,10 @@ std::size_t search_for_symbols(const std::vector& plugi int main(int argc, char* argv[]) { BOOST_ASSERT(argc >= 3); std::vector plugins; - plugins.push_back(argv[1]); - plugins.push_back(argv[2]); + plugins.reserve(argc - 1); + for (int i = 1; i < argc; ++i) { + plugins.push_back(argv[i]); + } const std::size_t res = search_for_symbols(plugins); BOOST_ASSERT(res == 1); diff --git a/example/tutorial5/load_all.cpp b/example/tutorial5/load_all.cpp index 283308e..2bd03fd 100644 --- a/example/tutorial5/load_all.cpp +++ b/example/tutorial5/load_all.cpp @@ -112,15 +112,20 @@ int main(int argc, char* argv[]) { /*<-*/ BOOST_ASSERT(argc >= 3); boost::filesystem::path path1(argv[1]); - boost::filesystem::path path2(argv[2]); - boost::filesystem::path res; - for (boost::filesystem::path::iterator it1 = path1.begin(), it2 = path2.begin(); - it1 != path1.end() && it2 != path2.end() && *it1 == *it2; - ++it1, ++it2) - { - res /= *it1; + for (int i = 2; i < argc; ++i) { + boost::filesystem::path path2(argv[i]); + boost::filesystem::path res; + for (boost::filesystem::path::iterator it1 = path1.begin(), it2 = path2.begin(); + it1 != path1.end() && it2 != path2.end() && *it1 == *it2; + ++it1, ++it2) + { + res /= *it1; + } + + path1 = res; } - std::string new_argv = res.string(); + + std::string new_argv = path1.string(); std::cout << "\nPlugins path: " << new_argv << ":\n"; argv[1] = &new_argv[0]; /*->*/ diff --git a/example/tutorial7/tutorial7.cpp b/example/tutorial7/tutorial7.cpp index bba5c04..07aebcc 100644 --- a/example/tutorial7/tutorial7.cpp +++ b/example/tutorial7/tutorial7.cpp @@ -6,6 +6,7 @@ // or copy at http://www.boost.org/LICENSE_1_0.txt) #include "../shared_lib_path.hpp" +#include //[callplugcpp_tutorial7 #include @@ -35,11 +36,11 @@ void load_and_execute(const boost::filesystem::path libraries[], std::size_t lib int main(int argc, char* argv[]) { /*<-*/ BOOST_ASSERT(argc >= 3); /*->*/ - const std::size_t libs_count = 2; - boost::filesystem::path libraries[libs_count] = { - argv[1], - argv[2], - }; + std::vector libraries; + libraries.reserve(argc - 1); + for (int i = 1; i < argc; ++i) { + libraries.push_back(argv[i]); + } - load_and_execute(libraries, libs_count); + load_and_execute(&libraries[0], libraries.size()); }