// Smoke test for the header-only part of Boost shipped in libboost-dev.

#include <boost/any.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/optional.hpp>
#include <boost/variant.hpp>

#include <cassert>
#include <iostream>
#include <string>

struct person
{
    std::string name;
    int age;
};

using namespace boost::multi_index;

typedef multi_index_container<
    person,
    indexed_by<ordered_unique<member<person, std::string, &person::name> >,
               ordered_non_unique<member<person, int, &person::age> > > >
    person_set;

int main()
{
    person_set people;
    people.insert({ "alice", 42 });
    people.insert({ "bob", 23 });
    people.insert({ "carol", 31 });

    assert(people.size() == 3);
    assert(people.find("bob")->age == 23);

    const person_set::nth_index<1>::type &by_age = people.get<1>();
    std::cout << "youngest: " << by_age.begin()->name << std::endl;
    assert(by_age.begin()->name == "bob");

    boost::optional<int> maybe;
    assert(!maybe);
    maybe = 7;
    assert(maybe && *maybe == 7);

    boost::variant<int, std::string> v = std::string("boost");
    assert(boost::get<std::string>(v) == "boost");
    v = 3;
    assert(boost::get<int>(v) == 3);

    boost::any a = 3.5;
    assert(boost::any_cast<double>(a) == 3.5);

    std::cout << "header-only components OK" << std::endl;

    return 0;
}
