Skip to content

Commit 4d41a98

Browse files
committed
Updated deprecated uses of boost/bind.hpp, replaced standard function wrappers.
boost/bind.hpp generates deprecation warnings about global placeholder argument keywords. This commit updates to boost/bind/bind.hpp and namespaced keywords. Also, this commit replaces standard function object wrappers, which were removed from C++20, with boost::bind.
1 parent fcffe08 commit 4d41a98

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

example/options_heirarchy.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
//
2222

2323
#include <boost/program_options.hpp>
24-
namespace po = boost::program_options;
2524
#include <string>
2625
#include <iostream>
2726
#include <map>
2827
#include <stdexcept>
2928
#include <fstream>
29+
#include <boost/bind/bind.hpp>
30+
31+
namespace po = boost::program_options;
3032

3133
const std::string version("1.0");
3234

@@ -221,7 +223,7 @@ class OptionsHeirarchy
221223
// The next two lines are the crazy syntax to use EnvironmentMapper as
222224
// the lookup function for env->config name conversions
223225
boost::function1<std::string, std::string>(
224-
std::bind1st(std::mem_fun(&OptionsHeirarchy::EnvironmentMapper), this))),
226+
boost::bind(&OptionsHeirarchy::EnvironmentMapper, this))),
225227
results);
226228
notify(results);
227229
}

src/cmdline.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <boost/program_options/positional_options.hpp>
1616
#include <boost/throw_exception.hpp>
1717

18-
#include <boost/bind.hpp>
18+
#include <boost/bind/bind.hpp>
1919

2020
#include <string>
2121
#include <utility>
@@ -224,24 +224,24 @@ namespace boost { namespace program_options { namespace detail {
224224

225225
if (m_additional_parser)
226226
style_parsers.push_back(
227-
boost::bind(&cmdline::handle_additional_parser, this, _1));
227+
boost::bind(&cmdline::handle_additional_parser, this, boost::placeholders::_1));
228228

229229
if (m_style & allow_long)
230230
style_parsers.push_back(
231-
boost::bind(&cmdline::parse_long_option, this, _1));
231+
boost::bind(&cmdline::parse_long_option, this, boost::placeholders::_1));
232232

233233
if ((m_style & allow_long_disguise))
234234
style_parsers.push_back(
235-
boost::bind(&cmdline::parse_disguised_long_option, this, _1));
235+
boost::bind(&cmdline::parse_disguised_long_option, this, boost::placeholders::_1));
236236

237237
if ((m_style & allow_short) && (m_style & allow_dash_for_short))
238238
style_parsers.push_back(
239-
boost::bind(&cmdline::parse_short_option, this, _1));
239+
boost::bind(&cmdline::parse_short_option, this, boost::placeholders::_1));
240240

241241
if ((m_style & allow_short) && (m_style & allow_slash_for_short))
242-
style_parsers.push_back(boost::bind(&cmdline::parse_dos_option, this, _1));
242+
style_parsers.push_back(boost::bind(&cmdline::parse_dos_option, this, boost::placeholders::_1));
243243

244-
style_parsers.push_back(boost::bind(&cmdline::parse_terminator, this, _1));
244+
style_parsers.push_back(boost::bind(&cmdline::parse_terminator, this, boost::placeholders::_1));
245245

246246
vector<option> result;
247247
vector<string>& args = m_args;

src/convert.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <boost/program_options/detail/utf8_codecvt_facet.hpp>
2020
#include <boost/throw_exception.hpp>
2121

22-
#include <boost/bind.hpp>
22+
#include <boost/bind/bind.hpp>
2323

2424
using namespace std;
2525

@@ -89,6 +89,7 @@ namespace boost {
8989
from_8_bit(const std::string& s,
9090
const std::codecvt<wchar_t, char, std::mbstate_t>& cvt)
9191
{
92+
using namespace boost::placeholders;
9293
return detail::convert<wchar_t>(
9394
s,
9495
boost::bind(&std::codecvt<wchar_t, char, mbstate_t>::in,
@@ -100,6 +101,7 @@ namespace boost {
100101
to_8_bit(const std::wstring& s,
101102
const std::codecvt<wchar_t, char, std::mbstate_t>& cvt)
102103
{
104+
using namespace boost::placeholders;
103105
return detail::convert<char>(
104106
s,
105107
boost::bind(&codecvt<wchar_t, char, mbstate_t>::out,

src/parsers.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <boost/program_options/environment_iterator.hpp>
1717
#include <boost/program_options/detail/convert.hpp>
1818

19-
#include <boost/bind.hpp>
19+
#include <boost/bind/bind.hpp>
2020
#include <boost/throw_exception.hpp>
2121

2222
#include <cctype>
@@ -75,12 +75,12 @@ namespace boost { namespace program_options {
7575

7676
std::transform(opt.value.begin(), opt.value.end(),
7777
back_inserter(result.value),
78-
boost::bind(from_utf8, _1));
78+
boost::bind(from_utf8, boost::placeholders::_1));
7979

8080
std::transform(opt.original_tokens.begin(),
8181
opt.original_tokens.end(),
8282
back_inserter(result.original_tokens),
83-
boost::bind(from_utf8, _1));
83+
boost::bind(from_utf8, boost::placeholders::_1));
8484
return result;
8585
}
8686
}

test/test_convert.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
#include <sstream>
1111
#include <iostream>
1212
#include <boost/progress.hpp>
13-
#include <boost/bind.hpp>
14-
#include <boost/ref.hpp>
1513

1614
#include <boost/program_options/detail/convert.hpp>
1715
#include <boost/program_options/detail/utf8_codecvt_facet.hpp>

0 commit comments

Comments
 (0)