|
Boost Users : |
Subject: Re: [Boost-users] Bug when using boost::optional with boost::program_options?
From: Jim Porter (jvp4846_at_[hidden])
Date: 2018-06-05 21:41:00
On 6/5/2018 8:51 AM, Xavier Besseron wrote:
> I remember having some troubles using |boost::optional| with
> |boost::program_options|.
> I fixed it by adding the following lines:
[snip]
> I donât remember the details, but I think I took that from more recent
> version of Boost to be able to use my code with older version of Boost.
> With that, my code compiles and runs fine
>
> * on Linux for Boost from 1.54 to 1.66 with various compilers (GCC 4.8
> to 7.3, Intel Compiler, Clang)
> * on Windows for Boost 1.60 with MSVC++ from 9 (2008) to 14 (2015).
I finally got everything working, and based on your code, you'll have
the same issue if you start using Boost 1.62+ on MSVC.
I didn't delve too deep into the why, but putting your `validate`
function in the `boost` namespace and `using namespace
boost::program_options` will introduce an ambiguity when constructing a
`boost::optional` (it's trying to find the `detail` namespace and gets
confused). I resolved it like this:
<https://github.com/jimporter/mettle/blob/7ea222a58537bd366ec0cf864de30d2969563d41/include/mettle/driver/cmd_line.hpp#L116-L131>.
Thanks again for the pointer!
- Jim
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net