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

  • Home
  • SEARCH
  • 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 3342984
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:54:09+00:00 2026-05-18T00:54:09+00:00

I need to be able to have boost::program_options parse an array of doubles that

  • 0

I need to be able to have boost::program_options parse an array of doubles
that are passed on a command line. For positive doubles, this is no problem,
of course (use multitoken with std::vector<double> in add_options), but for
negative ones, I know that these are ambiguous arguments.

Here is a demonstration of what I would like to take in:

mycommand --extent -1.0 -2.0 -3.0 1.0 2.0 3.0 --some-other-argument somevalue

extent is to be backed by a Bounds class with at least one constructor
that takes in six individual T arguments (in this case — double).

template <typename T>
class Bounds
{
public:
    typedef T value_type;
    typedef typename std::vector< Range<T> >::size_type size_type;

    typedef typename std::vector< Range<T> > Ranges;

    Bounds( T minx, T miny, T minz, 
            T maxx, T maxy, T maxz)
    {
        // fill Ranges vector
    }

private:
    Ranges ranges;
};

What else must I supply to support using add_options take in the Bounds class? I’d
like to do something similar to this. Possible?

namespace po = boost::program_options;
po::options_description options("options");

options.add_options()
    ("extent,e", po::value< Bounds< double > >(), "Extent to clip points to")

po::variables_map vm;
po::store(po::command_line_parser(argc, argv).
  options(options).positional(p).run(), vm);

po::notify(vm);

if (vm.count("extent")) 
{
    Bounds<double> bounds = vm["extent"].as< Bounds<double> >();
    // do other stuff
}
  • 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-18T00:54:10+00:00Added an answer on May 18, 2026 at 12:54 am

    The approach to handling negative numbers specified here might also work for you.

    I was parsing it by the simple parser

    store(command_line_parser(argc, argv).options(commands).run(), vm);
    

    , but solution was to use the extended
    one:

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

Sidebar

Related Questions

I need to be able to take an arbitrary text input that may have
I have a bunch of files that I need to be able to transport
I have a project that I'm working on and I need to be able
I need customers to be able to download PDFs of letters that have been
I have a situation where I need to be able to load assemblies in
I have a business case whereby I need to be able to specify my
In my engine I have a need to be able to detect DXT1 textures
I have a large amount of data I need to store, and be able
I need to be able to create basic MS Project items (tasks, projects, resources,
I need to be able to get at the full URL of the page

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.