Skip to content

Commit 8d5103d

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 fafcca1 commit 8d5103d

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
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: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,24 +228,24 @@ namespace boost { namespace program_options { namespace detail {
228228

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

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

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

241241
if ((m_style & allow_short) && (m_style & allow_dash_for_short))
242242
style_parsers.push_back(
243-
boost::bind(&cmdline::parse_short_option, this, _1));
243+
boost::bind(&cmdline::parse_short_option, this, boost::placeholders::_1));
244244

245245
if ((m_style & allow_short) && (m_style & allow_slash_for_short))
246-
style_parsers.push_back(boost::bind(&cmdline::parse_dos_option, this, _1));
246+
style_parsers.push_back(boost::bind(&cmdline::parse_dos_option, this, boost::placeholders::_1));
247247

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

250250
vector<option> result;
251251
vector<string>& args = m_args;

src/convert.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ namespace boost {
9292
from_8_bit(const std::string& s,
9393
const std::codecvt<wchar_t, char, std::mbstate_t>& cvt)
9494
{
95+
using namespace boost::placeholders;
9596
return detail::convert<wchar_t>(
9697
s,
9798
boost::bind(&std::codecvt<wchar_t, char, mbstate_t>::in,
@@ -103,6 +104,7 @@ namespace boost {
103104
to_8_bit(const std::wstring& s,
104105
const std::codecvt<wchar_t, char, std::mbstate_t>& cvt)
105106
{
107+
using namespace boost::placeholders;
106108
return detail::convert<char>(
107109
s,
108110
boost::bind(&codecvt<wchar_t, char, mbstate_t>::out,

src/parsers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ namespace boost { namespace program_options {
7878

7979
std::transform(opt.value.begin(), opt.value.end(),
8080
back_inserter(result.value),
81-
boost::bind(from_utf8, _1));
81+
boost::bind(from_utf8, boost::placeholders::_1));
8282

8383
std::transform(opt.original_tokens.begin(),
8484
opt.original_tokens.end(),
8585
back_inserter(result.original_tokens),
86-
boost::bind(from_utf8, _1));
86+
boost::bind(from_utf8, boost::placeholders::_1));
8787
return result;
8888
}
8989
}

test/test_convert.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
#include <sstream>
1414
#include <iostream>
1515
#include <boost/progress.hpp>
16-
#include <boost/bind.hpp>
17-
#include <boost/ref.hpp>
1816

1917
#include <boost/program_options/detail/convert.hpp>
2018
#include <boost/program_options/detail/utf8_codecvt_facet.hpp>

0 commit comments

Comments
 (0)