Boost logo

Boost Users :

Subject: Re: [Boost-users] Command Line Options Questions
From: Daniel Hofmann (daniel_at_[hidden])
Date: 2016-03-06 15:50:10

You have to implement operator<< otherwise the compiler does not know how to print (pipe it into an ostream) dsp_type.

You can use Boost.Fusion's I/O feature and BOOST_ADAPT_STRUCT like this
to make your life easier.

On March 6, 2016 5:43:27 PM GMT+01:00, Jon Lederman <jonlederman_at_[hidden]> wrote:
>I have two questions re: the boost command line options library:
>1) I am compiling a dynamic library that links to the boost command
>line options library as a shared library. When I try to unload the
>dynamic library, I find that it isn’t properly unloaded and the boost
>library seems to be causing the issue. I did find that things were
>helped somewhat when I linked to the boost static libraries. However,
>it still feels unstable. Are there any particular things I should know
>about in this context in terms of how my makefile should be linking to
>boost? Or are there other things I should look at.
>2) When using program options, I am getting the following error. For
>some reason this seemed to work with the dynamic libraries (or it may
>be a coincidence). Am I required to implement the << and >> operators?
>It had been compiling previously and stopped. After googling this
>issue there seems to be a lot of confusion. Any help would be greatly
>in file included from /usr/include/boost/any.hpp:27:0,
> from /usr/include/boost/program_options/value_semantic.hpp:12,
> from /usr/include/boost/program_options/options_description.hpp:13,
> from /usr/include/boost/program_options.hpp:15,
>/usr/include/boost/lexical_cast.hpp: In instantiation of 'struct
>/usr/include/boost/lexical_cast.hpp:415:89: required from 'struct
>/usr/include/boost/lexical_cast.hpp:674:92: required from 'struct
>/usr/include/boost/lexical_cast.hpp:2363:19: required from 'static
>Target boost::detail::lexical_cast_do_cast<Target,
>Source>::lexical_cast_impl(const Source&) [with Target = dsp_type;
>Source = std::basic_string<char>]'
>/usr/include/boost/lexical_cast.hpp:2543:50: required from 'Target
>boost::lexical_cast(const Source&) [with Target = dsp_type; Source =
>required from 'void boost::program_options::validate(boost::any&, const
>std::vector<std::basic_string<charT> >&, T*, long int) [with T =
>dsp_type; charT = char]'
>required from 'void boost::program_options::typed_value<T,
>charT>::xparse(boost::any&, const std::vector<std::basic_string<charT>
>>&) const [with T = dsp_type; charT = char]'
> required from here
>/usr/include/boost/lexical_cast.hpp:388:13: error: static assertion
>failed: Target type is neither std::istream`able nor std::wistream`able
>BOOST_STATIC_ASSERT_MSG((result_t::value ||
>boost::has_right_shift<std::basic_istream<wchar_t>, T >::value),
> ("help", "Generates help message")
> ("dsp_type", po::value<dsp_type>(&params.dsp_type)->required(), “")
>where dsp_type is this:
>struct dsp_type {
> dsp_type() {}
> dsp_type(std::string const& val):
> value(val)
> { }
> std::string value;
>and I have a validator defined as this:
>void validate(boost::any& v,
> std::vector<std::string> const& values,
> dsp_type* /* target_type */,
> int)
> using namespace boost::program_options;
> //namespace po = boost::program_options;
> // Make sure no previous assignment to 'v' was made.
> validators::check_first_occurrence(v);
> // Extract the first string from 'values'. If there is more than
> // one string, it's an error, and exception will be thrown.
> std::string const& s = validators::get_single_string(values);
>if (s == "ladspa" || s == "audioweaver" || s == "gstreamer" || s ==
>"lv2") {
> v = boost::any(dsp_type(s));
> } else {
> throw validation_error(validation_error::invalid_option_value);
> }
>/usr/local/src/freeswitch/build/modmake.rules:214: recipe for target
>'mod_sc_dsp.lo' failed
>make[1]: *** [mod_sc_dsp.lo] Error 1
>Boost-users mailing list

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at