Problem compiling

Hi!

So I started using the Boost library yesterday. And I've created some code that I want to test. But I can't get it to compile. Either it can't find EvEChecker.hpp or some strange errors appear that have nothing to do with my code.

Current code:
Main.cpp
1
2
3
4
5
6
7
8
9
10
11
#include <EvEChecker.hpp>

int main(){
    MarketItem mi34;
    mi34.load(34, "quicklook.xml");
    cout << mi34.getSellOrders().size()<< endl;
    return 0;



}


EvEChecker.hpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include <boost/foreach.hpp>
#include <string>
#include <set>
#include <exception>
#include <iostream>

using namespace std;

class Order{
    protected:
        string m_StationName,m_Expires, m_ReportedTime, m_OrderID;
        int m_Region, m_Station, m_Security, m_Range, m_Price, m_VolRemain, m_MinVolume;

    public:
        //constructor
        Order(string orderID, string stationName, string expires,string reported, int region, int station,int security, int range, int price, int volremain, int minvolume){
            m_OrderID = orderID;
            m_StationName = stationName;
            m_Expires = expires;
            m_ReportedTime = reported;
            m_Region = region;
            m_Station = station;
            m_Security = security;
            m_Range = range;
            m_Price = price;
            m_VolRemain = volremain;
            m_MinVolume = minvolume;
        }

        string getStationName(){return m_StationName;};
        string getExpires(){return m_Expires;};
        string getReportedTime(){return m_ReportedTime;};
        int getRegion(){return m_Region;};
        int getStation(){return m_Station;};
        int getSecurity(){return m_Security;};
        int getRange(){return m_Range;};
        int getPrice(){return m_Price;};
        int getVolRemain(){return m_VolRemain;};
        int getMinVolume(){return m_MinVolume;};

};

class MarketItem{
    protected:
        int m_ItemID, m_Hours, m_Minqty;
        string m_ItemName;
        //unigue Order IDs
        std::set<Order> m_SellOrders, m_BuyOrders;
    public:
        //get the data from the XML parser and extract the data
        void load(int, string);

        int getItemID(){return m_ItemID;};
        int getHours(){return m_Hours;};
        int getMinqty(){return m_Minqty;};
        string getItemName(){return m_ItemName;};

        //they don't need to change thereof const &
        const std::set<Order>& getSellOrders(){const std::set<Order>& temp = m_SellOrders; return temp;};
        const std::set<Order>& getBuyOrders(){const std::set<Order>& temp = m_BuyOrders; return temp;};

};

void MarketItem::load(int itemID, string filename){
    using boost::property_tree::ptree;
    ptree pt;

    read_xml(filename , pt);
    //load all the values
    m_ItemID = pt.get<int>("quicklook.item");
    m_ItemName = pt.get<std::string>("quicklook.itemname");
    m_Hours = pt.get<int>("quicklook.hours");
    m_Minqty = pt.get<int>("quicklook.minqty");

    BOOST_FOREACH(ptree::value_type const& v, pt.get_child("quicklook.sell_orders")){
        if(v.first == "order"){
            m_SellOrders.insert(Order(v.second.get<std::string>("<xmlattr.id>"), v.second.get<std::string>("station"), v.second.get<std::string>("expires"), v.second.get<std::string>("reported_time"),
                v.second.get<int>("region"), v.second.get<int>("station"), v.second.get<int>("security"), v.second.get<int>("range"), v.second.get<int>("price"),
                v.second.get<int>("vol_remain"), v.second.get<int>("min_volume")));
        }
    }
}


When I try to compile and run Main.cpp I get the following errors:

c:\program files (x86)\codeblocks\mingw\bin..\lib\gcc\mingw32\4.7.1\include\c++\bits\stl_function.h
and so on and so on. With errors on line 1285 and similar.

(apparently I can't paste the build messages correctly)




Any help?
Last edited on
This is the only error it finds, but then there is 4 warnings and a shitton of info from other places.

c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++/bits/stl_function.h:237:22: error: no match for 'operator<' in '__x < __y'
> error: no match for 'operator<' in '__x < __y'


For std::set<Order> to be feasible, Order must be LessThanComparable
http://www.sgi.com/tech/stl/LessThanComparable.html

Something like this is required:

1
2
3
4
5
6
7
8
9
10
11
class Order
{
        // ...
    public:
        // ...

        // *** added ***
        bool operator< ( const Order& that ) const { return m_OrderID < that.m_OrderID ; }

        // ...
};
Last edited on
ah!! ah!!!

Ok, so best option is to swap container or can I somehow make them orderable by orderID?

wait, that was what u just did
:P

ty ty
Last edited on
hmm... still gives me the same error...
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\stl_function.h|237|error: no match for 'operator<' in '__x < __y'|
Last edited on
> hmm... still gives me the same error...

Does it?

http://liveworkspace.org/code/7WfJh$0
yeah...

added the overloaded operator...



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include <boost/foreach.hpp>
#include <string>
#include <set>
#include <exception>
#include <iostream>

using namespace std;

class Order{
    protected:
        string m_StationName,m_Expires, m_ReportedTime, m_OrderID;
        int m_Region, m_Station, m_Security, m_Range, m_Price, m_VolRemain, m_MinVolume;

    public:
        //constructor
        Order(string orderID, string stationName, string expires,string reported, int region, int station,int security, int range, int price, int volremain, int minvolume){
            m_OrderID = orderID;
            m_StationName = stationName;
            m_Expires = expires;
            m_ReportedTime = reported;
            m_Region = region;
            m_Station = station;
            m_Security = security;
            m_Range = range;
            m_Price = price;
            m_VolRemain = volremain;
            m_MinVolume = minvolume;
        }

        bool operator< ( const Order& that ) const { return m_OrderID < that.m_OrderID ; }

        string getStationName(){return m_StationName;};
        string getExpires(){return m_Expires;};
        string getReportedTime(){return m_ReportedTime;};
        int getRegion(){return m_Region;};
        int getStation(){return m_Station;};
        int getSecurity(){return m_Security;};
        int getRange(){return m_Range;};
        int getPrice(){return m_Price;};
        int getVolRemain(){return m_VolRemain;};
        int getMinVolume(){return m_MinVolume;};

};

class MarketItem{
    protected:
        int m_ItemID, m_Hours, m_Minqty;
        string m_ItemName;
        //unigue Order IDs
        std::set<Order> m_SellOrders, m_BuyOrders;
    public:
        //get the data from the XML parser and extract the data
        void load(int, string);

        int getItemID(){return m_ItemID;};
        int getHours(){return m_Hours;};
        int getMinqty(){return m_Minqty;};
        string getItemName(){return m_ItemName;};

        //they don't need to change thereof const &
        const std::set<Order>& getSellOrders(){const std::set<Order>& temp = m_SellOrders; return temp;};
        const std::set<Order>& getBuyOrders(){const std::set<Order>& temp = m_BuyOrders; return temp;};

};

void MarketItem::load(int itemID, string filename){
    using boost::property_tree::ptree;
    ptree pt;

    read_xml(filename , pt);
    //load all the values
    m_ItemID = pt.get<int>("quicklook.item");
    m_ItemName = pt.get<std::string>("quicklook.itemname");
    m_Hours = pt.get<int>("quicklook.hours");
    m_Minqty = pt.get<int>("quicklook.minqty");

    BOOST_FOREACH(ptree::value_type const& v, pt.get_child("quicklook.sell_orders")){
        if(v.first == "order"){
            m_SellOrders.insert(Order(v.second.get<std::string>("<xmlattr.id>"), v.second.get<std::string>("station"), v.second.get<std::string>("expires"), v.second.get<std::string>("reported_time"),
                v.second.get<int>("region"), v.second.get<int>("station"), v.second.get<int>("security"), v.second.get<int>("range"), v.second.get<int>("price"),
                v.second.get<int>("vol_remain"), v.second.get<int>("min_volume")));
        }
    }
}
Hmm noticed that I can compile and build the EvEChecker.hpp with no errors
but can't do it on the main.cpp one.

Still gives me the same error though.
Last edited on
Topic archived. No new replies allowed.