Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 824291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:04:50+00:00 2026-05-15T03:04:50+00:00

I am using boost::program_options like this: namespace po = boost::program_options; po::options_description desc(Options); desc.add_options() (help,?,

  • 0

I am using boost::program_options like this:

namespace po = boost::program_options;
po::options_description desc("Options");
desc.add_options()
  ("help,?", "Show Options")
  ("capture-file,I", po::value<string>(), "Capture File")   
  ("capture-format,F", po::value<string>()->default_value("pcap"), "Capture File Format")
  ("output-file,O", po::value<string>()->default_value("CONOUT$"), "Output File");

po::variables_map vm;
po::store(po::command_line_parser(ac, av).options(desc)./*positional(pd).*/run(), vm);

If I pass the command line parameter -I hithere it works, but it I pass /I hithere boost throws a boost::bad_any_cast with a what() of ” failed conversion using boost::any_cast”.

Is it possible to use program_options to parse either /-delimitted or --delimitted options? Bonus question, can it be configured so that / and - set the same option, but are binary opposites of each other? For example, /verbose might mean verbose logging while -verbose might mean less verbose logging.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T03:04:50+00:00Added an answer on May 15, 2026 at 3:04 am

    To use / and -, use command_line_parser‘s style() method with the appropriate combination of style_t flags. For example:

    po::store(po::command_line_parser(ac, av)
        .options(desc)
        .style(po::command_line_style::default_style
            | po::command_line_style::case_insensitive
            | po::command_line_style::allow_slash_for_short
            | po::command_line_style::allow_long_disguise)
        /*.positional(pd)*/
        .run(), vm);
    

    (allow_long_disguise lets / start a long option.)

    You could probably make / and - opposites by adding your own additional parser; however, this would be very nonstandard and therefore potentially confusing to end users, so I’m not sure it’s a good idea.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 401k
  • Answers 401k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It throws an exception of the type EAbort. See the… May 15, 2026 at 4:25 am
  • Editorial Team
    Editorial Team added an answer Issue solved, changed mouseover and mouseout events to be return… May 15, 2026 at 4:25 am
  • Editorial Team
    Editorial Team added an answer The purpose is to avoid settling at a localised best… May 15, 2026 at 4:25 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.