Boost logo

Boost Users :

From: chun ping wang (cablepuff_at_[hidden])
Date: 2007-11-13 22:37:13


Hi i would like to know how to make program options play nicely with tuple.
int main( int ac, char* av[] )
{
        namespace po = boost::program_options;
    po::options_description desc("Allowed options");
    std::vector<BigInteger> key_pair;
    desc.add_options()
                ("generate", "generates a pair of key")
                ("secert", po::value(&key_pair)->multitoken(), "creates the share
secret key");

        po::variables_map vm;
        po::store(po::parse_command_line(ac, av, desc), vm);
        po::notify(vm);

        try
        {
                if (vm.count("generate"))
                {
                        BigInteger my_prime =
encryptcpw::random_prime<BigInteger>(&algocpw::Solovay_Stressen<BigInteger>,
16);
                        std::cout << "my prime: " << my_prime << "\n";
                        boost::tuple<BigInteger, BigInteger> pare(encryptcpw::dh_init<BigInteger>(
                                 my_prime
                        ));
                        std::cout << "pair of generated number: " << pare << "\n";
                }
                if (vm.count("secert"))
                {
                        const BigInteger p(
encryptcpw::random_prime<BigInteger>(&algocpw::Solovay_Stressen<BigInteger>,
16));
                        std::cout << encryptcpw::dh_secret<BigInteger>(
                                                         p,
                                                         key_pair[0],
                                                         key_pair[1]);

                }
        }
        catch (const char* error)
        {
                std::cerr << error << "\n";
        }
}

I would like to replace vector with tuple.
boost::tuple<BigInteger, BigInteger> key_pair;

for some reason doing that cause the program to crash.. when run
DiffieHellman --generate 1371 2397


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