I found a lot of books introduce about objective C but can't find a book which talk about objective C++.Could you introduce me an objective C++ textbook? I learned C++ before but don't know objective C, where should I start if I want to learn objective C++?Looks like it is a superset of C++?Could it co-work with some of the features of C++11? Thank you very much

Member Avatar
Member Avatar
+0 forum 4

template<typename View> struct pixel_traits; template<> struct pixel_traits<gray8c_view_t> { typedef gray8c_pixel_t type; } Could I find something like this from gil?Thanks

Member Avatar
+0 forum 0

#ifndef EXAMPLE_HPP #define EXAMPLE_HPP #include <memory> #include <boost/gil/gil_all.hpp> #include <QtGui/QApplication> #include <QtGui/QHBoxLayout> #include <QtGui/QImage> #include <QtGui/QLabel> #include <QtGui/QWidget> //#include "image_details.hpp" static void x_gradient(boost::gil::gray8c_view_t const &src, boost::gil::gray8s_view_t const &dst) { for (int y = 0; y != src.height(); ++y) for (int x = 1; x != src.width() - 1; ++x) dst(x, y) = (src(x - 1, y) - src(x + 1, y)) / 2; } inline void ComputeXGradientGray8(unsigned char const *src_pixels, ptrdiff_t src_row_bytes, int w, int h, unsigned char *dst_pixels, ptrdiff_t dst_row_bytes) { using namespace boost::gil; gray8c_view_t src = interleaved_view(w, h, (const gray8_pixel_t*)src_pixels, src_row_bytes); gray8s_view_t dst = interleaved_view(w, h, ( gray8s_pixel_t*)dst_pixels, …

Member Avatar
Member Avatar
+0 forum 2

Recently I am studying GIL and concept(htp://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2081.pdf) and encounter a lot of problems. concept ChannelConcept<typename T> : EqualityComparable<T> { typename value_type = T; // use channel_traits<T>::value_type to access it where ChannelValueConcept<value_type>; //tag1 typename reference = T&; // use channel_traits<T>::reference to access it typename pointer = T*; // use channel_traits<T>::pointer to access it typename const_reference = const T&; // use channel_traits<T>::const_reference to access it typename const_pointer = const T*; // use channel_traits<T>::const_pointer to access it static const bool is_mutable; // use channel_traits<T>::is_mutable to access it static T min_value(); // use channel_traits<T>::min_value to access it static T max_value(); // use channel_traits<T>::min_value to …

Member Avatar
+0 forum 0

I would like to study the source codes of openCV and reimplement them by the boost generic image library, I hope the algorithms developed by GIL could be integrated with Qt seamlessly. There are many libraries of image processing and I don't need to implement them again if I only want to develop some app, I would like to do this because I want to learn something from surveying the source codes of openCV(looks like this is a well design library) and the generic image library. I haven't studied GIL yet, anybody who studied GIL could give me some advices? …

Member Avatar
Member Avatar
+0 forum 2

Code blocks are created by indenting at least 4 spaces ... and can span multiple lines class Wizard : public QDialog { Q_OBJECT public: Wizard(QWidget *parent); private slots: void what_ever(); private: QPushButton *what_ever; }; Wizard::Wizard( QWidget *parent ) : QDialog(parent) { QGridLayout *layout = new QGridLayout( this ); QScopedPointer<QTextEdit> textEdit(new QTextEdit); layout->addWidget( textEdit.take(), 0, 0, 1, 2 ); what_ever = new QPushButton("whatever"); layout->addWidget(what_ever, 0, 1, 1, 1); connect(what_ever, SIGNAL(clicked()), this, SLOT(what_ever())); } void Wizard::what_ever() { //blah blah blah } I have some problems about the codes. 1 : What if textEdit throw exception? If "textEdit" throw exception, that means the …

Member Avatar
Member Avatar
+0 forum 1

I saw the movie from the link[URL="http://channel9.msdn.com/Events/GoingNative/GoingNative-2012/Keynote-Bjarne-Stroustrup-Cpp11-Style"]http://channel9.msdn.com/Events/GoingNative/GoingNative-2012/Keynote-Bjarne-Stroustrup-Cpp11-Style[/URL] Could I find something like std::async from boost?Thanks a lot

Member Avatar
Member Avatar
+0 forum 2

Could I find some translator which could translate partial C++ codes to equivalent C codes? like [code] int max(int A, int B); double max(double B, double B); [/code] would be translate to something like [code] int maxInt(int A, int B); double maxDouble(double B, double B); [/code] [code] template<typename T = int, double, char> T max(T A, T B); [/code] would be translate to something like [code] int maxInt(int A, int B); double maxDouble(double B, double B); char maxChar(char B, char B); [/code] Or I should write one for myself? Ok, I know that I should use C++ if I like …

Member Avatar
Member Avatar
+0 forum 3

I am studying the source codes of SGI STL and have many problems with it. I can't figure out the design choice of the iterator of SGI STL as follow [code] template <class _Tp, class _Ref, class _Ptr> struct _Slist_iterator : public _Slist_iterator_base { typedef _Slist_iterator<_Tp, _Tp&, _Tp*> iterator; #1 typedef _Slist_iterator<_Tp, const _Tp&, const _Tp*> const_iterator; #2 typedef _Slist_iterator<_Tp, _Ref, _Ptr> _Self; #3 }; [/code] Why don't just change the _Slist_iterator to the way as #4 and #5 [code] template <class _Tp> struct _Slist_iterator : public _Slist_iterator_base { typedef _Slist_iterator<_Tp> iterator; #4 typedef _Slist_iterator<_Tp> const iterator const_iterator; #5 }; …

Member Avatar
Member Avatar
+0 forum 4

I discover a performance pitfall of vc2010, I compile it by release mode(O2).The results are pretty unacceptable at the first time. [code] #include<ctime> #include<iostream> /* * This is a small performance pitfall I discover from vc2010, * for simplicity, I didn't separate the header file and source file. * At first, I wonder that maybe the template of vc2010 has some problem, * so I use void* to instead template, yet the result is the same.After * some trials and errors, I discover the problem, let us take a look. */ /* Estimate the execution time of function like object …

Member Avatar
Member Avatar
+0 forum 1

When I was a student, I believe that most of the software programmers of every software companies must be very talented, brilliant, skillful and much more experience than me, at least before I got my first job, I really believe that every software companies could let me learn a lot.But now, when I look at the source codes of our company, I really believe that there are some(or a lot of) programmers don't even have the abilities to write a simple fizzbuzz program. This post would introduce some horrible errors and many less efficient codes of our companies, I post …

Member Avatar
Member Avatar
+0 forum 14

I am trying to write some simple programs related to network and I boost::asio as a tool to start with Below is one of the example from a blog(I alter it a little bit) [code] void OnConnect(const boost::system::error_code & ec) {} void asio_7b() { asio::io_service io_service; asio::ip::tcp::socket sock(std::ref(io_service) ); try { boost::asio::ip::tcp::resolver resolver( std::ref(io_service) ); boost::asio::ip::tcp::resolver::query query( "www.google.com", "80" ); boost::asio::ip::tcp::endpoint endpoint = resolver.resolve( query ); std::cout << "Connecting to: " << endpoint << std::endl; sock.async_connect( endpoint, boost::bind( OnConnect, _1) ); #1 } catch( std::exception & ex ) { std::cout << "[" << boost::this_thread::get_id() << "] Exception: " << ex.what() …

Member Avatar
Member Avatar
+0 forum 1

[code] struct String { String() { std::cout<<"String::String(), this="<<this<<std::endl; } ~String() { std::cout<<"String::~String(), this="<<this<<std::endl; } String(String const &other) { std::cout<<"String::String(String const &other), this="<<this; std::cout<<", other="<<&other<<std::endl; } String& operator=(String const &other) { std::cout<<"String::operator=(String const &other), this="<<this; std::cout<<", other="<<&other<<std::endl; return *this; } }; String const operator*(String const &lhs, String const &rhs) { String temp(rhs); std::cout<<"return by value(* operator)"<<std::endl; return temp; //without copy construct } int main() { std::cout<<"***************value******************"<<std::endl; String D; String E; String F; D = E * F; std::cout<<"***************value******************"<<std::endl<<std::endl; std::cin.get(); return 0; } [/code] Compiler vc2010 OS win7 64bits I expected it would copy construct temp before calling copy assignment What kind …

Member Avatar
Member Avatar
+0 forum 4

I need to make the last 5 bits of the unsigned int become zero(1111_1111 to 1110_0000) There are two solution [code] unsigned int number = 0xFFFF; unsigned int temp_one = number & (~0x1F); unsigned int temp_two = number >> 5 << 5; [/code] which one is faster? I write a small program to measure the time But it is always 0 after optimize Thanks a lot

Member Avatar
Member Avatar
+0 forum 4

compiler : visual c++ 2005 os : win7 64bits The more I study about our source codes, the more dense fogs surround my head. According to what I know, memset can't be used to initialize POD This is the snippet of our codes(The problem of encapsulation? there are too many public or protected data members in our codes without any special reason--except of "this is convenience", I am tired to refine this). [code] //non POD type struct MessageQueryTester { public: void querySupportModel() {} unsigned int supportedModelSize() { return 0; } const char* supportedModel(unsigned int index) { return "keke"; } void …

Member Avatar
Member Avatar
+0 forum 5

If this is not a right place to post this article, please move it to another way, thank you very much. Sometimes(or always) giving a name to a class or variable is not an easy job, I want to make it expressive and short, how do you solve this kind of problem? Although this may not a big problem at the beginning, but when the project become bigger and bigger, I find out that good name of class and variable could be useful, a good name could make the program easier to read, less ambiguity, and it could be more …

Member Avatar
Member Avatar
+0 forum 3

I don't know should I post this article at here or not, if you think this should belongs to other area, please move it to there. I need to design some domain specific language to generate some C++ source codes. I have considered about using xml directly instead of designing a new DSL. but it is too verbose and complicated for my case, so I decided to design an easier one for myself(besides, this is a good practice, maybe). I am using and learning boost::spirit, because it is robust, flexible, good performance, easy to maintain .But my colleague said spirit …

Member Avatar
Member Avatar
+0 forum 2

[code] #include<iostream> #include<string> #include<vector> #include<boost/spirit/include/phoenix.hpp> #include<boost/spirit/include/karma.hpp> struct test_spirit { void read_function(std::string &result, std::string const &val) const { if(result != "memo_zero") result += val; } }; void spirit_01b() { std::vector<std::string> data; data.push_back("memo_zero"); data.push_back("memo_two"); data.push_back("memo_three"); std::string temp; test_spirit ts; karma::generate ( std::back_inserter(temp), ( karma::string[phoenix::bind(&test_spirit::read_function, &ts, karma::_1, karma::_val)] << ", " ), data, data ); std::cout<<temp<<std::endl; std::cin.get(); } [/code] The desired output is "memo_two, memo_three, "(I don't know how to get rid of the last ", ") The type pass into the function is "std::vector<std::string>" but what I need is std::string How could I pass in std::string? After some experiment, I think semantic …

Member Avatar
Member Avatar
+0 forum 3

I would like to generate output like this common, int, optional video, double, optional by karma with the structure [code] struct attr_struct { std::vector<std::string> name; std::vector<std::string> type; std::vector<std::string> use; }; [/code] So I defined some rules for it [code] #include<iostream> #include<string> #include<vector> #include<boost/fusion/adapted/struct.hpp> #include<boost/spirit/include/karma.hpp> namespace karma = boost::spirit::karma; namespace karma = boost::spirit::karma; struct attr_struct { std::vector<std::string> name; std::vector<std::string> type; std::vector<std::string> use; }; BOOST_FUSION_ADAPT_STRUCT ( attr_struct, (std::vector<std::string>, name) (std::vector<std::string>, type) (std::vector<std::string>, use) ); struct attr_grammar : karma::grammar<std::back_insert_iterator<std::string>, attr_struct()> { attr_grammar() : attr_grammar::base_type(query) { key = karma::delimit(", ") [karma::string << karma::string << karma::string] << karma::eol; query = key; //this one work //query …

Member Avatar
Member Avatar
+0 forum 2

I take some codes from [url]http://boost-spirit.com/home/articles/karma-examples/output-generation-from-a-list-of-key-value-pairs-using-spirit-karma/[/url] But it wouldn't compile My compiler : vc++ 2010 os : win7 64bits [code] #include<iostream> #include<string> #include<boost/optional.hpp> #include<boost/spirit/include/karma.hpp> namespace karma = boost::spirit::karma; namespace phoenix = boost::phoenix; int main() { typedef std::back_insert_iterator<std::string> sink_type; karma::rule<sink_type, std::string()> base = karma::string; typedef std::pair<std::string, boost::optional<std::string> > pair_type; karma::rule<sink_type, pair_type()> pair; pair = karma::string << -('=' << karma::string); //this line can't be compiled std::cout<<"system pause"<<std::endl; std::cin.get(); return 0; } [/code] error message of vc++ 2010 error C2146: syntax error : missing ';' before identifier 'type' error C4430: missing type specifier - int assumed. Note: C++ does not support default-int error …

Member Avatar
Member Avatar
+0 forum 2

[code] void airplaneTest::SetUp() { ASSERT_TRUE(this->msg_handler_.install_airplane(GetParam()) << "Failed to install airplane " << GetParam(); airplane_id_ = airplane.airplane_id(); } void airplaneTest::TearDown() { ASSERT_FALSE(airplane_id_.empty() ); ASSERT_TRUE(this->msg_handler_.remove_airplane(airplane_id_)) << "Failed to remove airplane " << GetParam(); } //a lot of test case put into TEST_P [/code] Google test will reinstall the airplane for diffrent test cases But the action of install and remove are very expensive What I would like to do is only install and remove when the specific airplane(identify by GetParam) finish all of the test cases Could I finish this kind of job with google test? Thanks a lot

Member Avatar
+0 forum 0

Now I have a lot of airplanes, in the ideal world the interface of the airplanes(or anything) should be unify but for some kind of weird reasons, the class for different airplanes are designed like this [code] struct airplane_A { fly_A(); speed_up_A(); //blah blah blah }; struct airplane_B { fly_B(); speed_up_B(); //blah blah blah }; [/code] Actually, the interfaces could be unified, but what is done is done. There are already more than 30 airplanes are designed like this If the interfaces of these airplanes are unify We don't need to write a lot of redundancy codes It could be …

Member Avatar
Member Avatar
+0 forum 3

desired output [code] void desired_output{ namespace karma = boost::spirit::karma; unsigned int A[] = {10, 9, 8, 7, 6}; std::vector<unsigned int> v(A, A + 5); std::string generated; for(size_t i = 0; i != v.size(); ++i) { std::cout<<v[i]<<" equal to "; karma::generate(std::back_inserter(generated), karma::uint_generator<unsigned int, 2>() << karma::eol, v[i]); std::cout<<generated; generated.clear(); } } [/code] This will output [quote] 10 equal to 1010 9 equal to 1001 8 equal to 1000 7 equal to 111 6 equal to 110 [/quote] [code] void desired_syntax{ namespace karma = boost::spirit::karma; unsigned int A[] = {10, 9, 8, 7, 6}; std::vector<unsigned int> v(A, A + 5); std::string generated; …

Member Avatar
+0 forum 0

I would like to make pugixml print the node_pi as [code] <?xml version="1.0" encoding="utf-8"?> [/code] How could I manipulate node_pi through pugixml? Thanks

Member Avatar
+0 forum 0

What is the meaning of attributes defined by boost::spirit? [code] namespace qi = boost::spirit::qi; qi rule<std::string::const_iterator, double()> simple_rule = qi::double_ >> *(',' >> qi::double_); [/code] only double_, int_ equal to attributes or ',' also is an attribute? Thanks

Member Avatar
+0 forum 0

compiler : visual c++ 2005 os : win7 64bits [code] #define PARSE_AND_SERIALIZE_WRAPPER(HANDLE, VENDOR) \ template<> \ struct parse_and_serialize_wrapper<HANDLE> \ { \ template<typename Request> \ bool serialize_req(Request &request, std::string &serialized_msg, \ xml_schema::namespace_infomap &xml_namespace, boost::mpl::vector<serialize_query>); \ }; \ \ template<typename Request> \ bool parse_and_serialize_wrapper<HANDLE>::serialize_req(Request &request, std::string &serialized_msg, \ xml_schema::namespace_infomap &xml_namespace, boost::mpl::vector<serialize_query>) \ { \ std::ostringstream oss; \ serialize_VENDOR_query_req_msgbody(oss, request, xml_namespace); \ serialized_msg.assign(oss.str()); \ return !serialized_msg.empty(); \ } [/code] It could compile before I spend the macro, but when I spend the macro like [code] PARSE_AND_SERIALIZE_WRAPPER(stupid_handle, titan); [/code] the compiler always give me the error messages [quote]C2017: illegal escape sequence[/quote] this code could …

Member Avatar
Member Avatar
+0 forum 1

I try some codes snippet from boost spirit, but it only incur a lot of error mesasges [code] #include<iostream> #include<string> #include<boost/spirit/include/qi.hpp> void spirit_01() { namespace qi = boost::spirit::qi; std::string input("1.0,2.0"); std::pair<double, double> p; qi::parse(input.begin(), input.end(), qi::double_ >> ",">>qi::double_, p); //#1 } [/code] After some struggle, I figured it out the compiler say it needs two arguments the correct answer is [code] double a, b; qi::parse(input.begin(), input.end(), qi::double_ >> ",">>qi::double_, a, b); [/code] What am I lack to make #1 compile?Thanks I choose boost::spirit to develop some parsers and source codes generator When I deal with something like xml or some …

Member Avatar
+0 forum 0

[code] <xs:complexType name="common"> <xs:attr name="audio" type="xs:string" use="required" /> <xs:attr name="firmware" type="xs:string" use="optional" /> <xs:attr name="recording" type="xs:unsignedShort" use="required"/> <xs:complexType/> [/code] I want to sort the xml above by attribute "use" and make sure all of the elements with "required" would be on top, something like [code] <xs:complexType name="common"> <xs:attr name="audio" type="xs:string" use="required" /> <xs:attr name="recording" type="xs:unsignedShort" use="required"/> <xs:attr name="firmware" type="xs:string" use="optional" /> <xs:complexType/> [/code] According to pugixml, call std::sort would not give user expected result because it would not affect the local handle which store in the iterator The easiest solution for me is make a copy of node "complexType" sort …

Member Avatar
Member Avatar
+0 forum 1

We already use a tool which called codeSynthesisXSD to transform xml into source codes of C++ Yet there are too many tedious routines could be automated. like [code] <xs:complexType name="common_t"> <xs:attribute name="channel_id" type="channel_id_st" use="optional" /> <xs:attribute name="audio_record" type="xs:string" use="required" /> <xs:attribute name="firmware" type="xs:string" use="optional" /> <xs:attribute name="login_id" type="xs:string" use="optional" /> <xs:attribute name="login_passwd" type="xs:string" use="optional" /> </xs:complexType> [/code] is equal to the C++ source codes like "code #1" [code] //"code #1" //type common_t is generated by CodeSynthesisXSD static void setCommon(common_t& request, channel_id_st& channel_id, std::string const& audio_record, std::string const& firmware, std::string const& login_id, std::string const& login_passwd) { if(request.channel_id().present()) request.channel_id(channel_id); request.audio_record(audio_record); if( request.firmware().present() …

Member Avatar
+0 forum 0

[code] struct S { double operator()(char, int&); }; int main() { boost::result_of<S(char, int&)>::type f = 3.14; // f has type double } [/code] OS : win7 compiler :gcc mingw4.6.2 error message : error: no class template named 'result' in 'struct S'| error: expected ';' before 'f'| error: 'type' is not a member of 'boost::result_of<S(char, int&)>'| according to [url]http://en.cppreference.com/w/cpp/types/result_of[/url] This should work, what am I lack?Thanks

Member Avatar
Member Avatar
+0 forum 1

The End.