- Strength to Increase Rep
- +5
- Strength to Decrease Rep
- -1
- Upvotes Received
- 3
- Posts with Upvotes
- 3
- Upvoting Members
- 3
- Downvotes Received
- 2
- Posts with Downvotes
- 1
- Downvoting Members
- 2
109 Posted Topics
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 … | |
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 | |
Re: [QUOTE]System programming: Learn C and get some basics in assembly.[/QUOTE] c is still dominate the field of system programming so many programmers would reject c++ when refer to system programming. "slow", "code bloat", "waste of memory", "over complicated" and so on Many of those system programmers believe that "c++ must … | |
#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, … | |
Re: you could use smart pointer instead of the raw pointer std::vector<std::auto_ptr<Object> > SpriteList; SpriteList.push_back(new Object); //if your compiler support unique_ptr, you could change auto_ptr to unique_ptr //unique_ptr is a much more better choice than auto_ptr like Scott Meyers said : "handle the resource by object" Besides, according to exceptional c++ … | |
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 … | |
Re: I don't know C# very well, but I know C, C++(primary language) and using java to develop some app on android(even I don't like the philosophy of java, everything should be object?pointer is too dangerous so we should not use it?you don't have to care about memory and so on).Before … | |
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 … | |
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 … | |
Re: 1 : use 3rd libraries, ex : openCV, CImg 2 : study the format of pgm and encode by yourself example of openCV #include<opencv2\core\core.hpp> #include<opencv2\highgui\highgui.hpp> int main() { cv::Mat img = cv::imread("lena.pgm", -1); cv::imshow("output image", img); cv::waitKey(); return 0; } | |
Re: compile by vc2010, coding style of C++11? [code] #include<algorithm> //for std::for_each, std::reverse and std::copy #include<array> //for std::array #include<iostream> //for std::cout, std::cin.get #include<iterator> //for std::ostream_iterator #include<string> template<typename T> void reverseString(T &value) { std::for_each(value.begin(), value.end(), [](std::string &fir) { std::reverse(fir.begin(), fir.end()); }); } int main() { std::array<std::string, 3> value = {"one", "two", "three"}; … | |
Re: Your codes are not bad, but there are still something could be refine [code] //this is not initialize but assignment Player::Player(int MyID, string MyFactionName) { ID=MyID; FactionName=MyFactionName; } [/code] [code] //This is initialize Player::Player(int MyID, string MyFactionName) :ID(MyID), FactionName(MyFactionName){ } [/code] [code] //you are intent to copy the string, use … | |
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 | |
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 = … | |
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 … | |
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 … | |
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 … | |
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 … | |
[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 … | |
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 … | |
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 … | |
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 … | |
Re: [QUOTE=;][/QUOTE] [quote]Here's a link to a read me thread in the Computer Science forum [/quote] The opinions are pretty good, but there are some things about C++ I don't agree with. >C++ is an Object Oriented Programming (or OOP) C++ is an multi-paradigms language >Programs can be slightly larger and … | |
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 … | |
[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, … | |
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 … | |
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()> … | |
[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 … | |
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(); … | |
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(); } } … | |
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 | |
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 | |
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>) \ … | |
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 … | |
[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" … | |
Re: [QUOTE=;][/QUOTE] or boost tokenizer [code] std::string mid_str("I have a dog"); typedef boost::tokenizer<boost::char_separator<char> > tokenizer; tokenizer tokens(mid_str, boost::char_separator<char> (" ")); std::string strArray[4]; std::copy(tokens.begin(), tokens.end(), strArray); [/code] | |
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" /> … | |
[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 … | |
This is codes snippet from our codes [code] void testSmartAssign() { boost::shared_ptr<int> A; std::auto_ptr<int> B(new int(9)); A = B; } [/code] Is this kind of assignment well defined? Thanks | |
I want to parse XML and change the contents of the XML Which one should I choose? boost::spirit or boost::serialization Thanks a lot | |
[code] class robot_generic { public : template<typename Request, typename Response> bool const queryDriver(Request const &req, Response &res) { //some jobs, blah blah blah } template<typename Request, typename Response> bool const queryMoney(Request const &req, Response &res) { //some jobs, blah blah blah } }; class robot_A : public robot_generic { public … | |
OS : win7 64bits compiler : visual C++ 2005 boost version : boost_1_44_0 [code] #include <gtest/gtest.h> #include <tchar.h> #include <boost/signal.hpp> #include <boost/bind.hpp> #include <boost/function.hpp> #include <boost/mem_fn.hpp> class Slot : public boost::signals::trackable { public: void Update(int) { ::printf("Signaled!!\n"); } }; int _tmain(int argc, _TCHAR* argv[]) { boost::signal<void (int)> s; Slot *slot … | |
I have some question about boost::promise After studying the website of boost and "C++ concurrency in action" I still can't get the idea of boost::promise According to the book(if I have no make any mistake) boost::future is designed for one off event you could wrap the task by packaged_task and … | |
I am studying CH4.3.2 of the book "C++ concurrency in action" , the book mention about "synchronizing with message passing" and give the reader some basic idea about it but without details(how to implement it). Could I find some simple examples which implement MPI by boost::thread? Since I haven't grasp … | |
Sometimes, when I want to move the project from path A:/B/C to path A:B/C/D/E, the relative path of the project have to be changed. I think I could write a small program to deduce the relative path after changed, it would be better if I could change the "Additional manipulate … | |
I like STL but the performance of the STL of visual C++ 2005 is not good enough, could I find some containers which looks like STL? Oops, I just found 1.48 release a brand new library--Container This library even support rvalue reference, so sweet. I love you, boost. Thanks | |
Re: simplest way [code] size_t A[] = {1, 1, 2, 3, 4, 4, 5}; size_t *APtr = std::unique(A, A + sizeof_array(A) ); std::copy(A, APtr + 1, std::ostream_iterator<size_t>(std::cout, "\n") ); [/code] or [code] //from cplus_plus.com size_t *unique_test( size_t *first, size_t *last ) { size_t *result = first; while (++first != last) { … | |
According to "modern c++ design", "effective c++", boost and loki. I believe that policy based design is very powerful(not mentioning about TMP yet). The idea of policy is pretty straight forward and easy, you don't need to be a template wizard or know TMP very well before you could use … | |
Re: [CODE] a1.reserve(size); for(int i = 0; i < size; i++) a1[i] = data [i]; [/CODE] reserve do not same as resize, reserve only change the capacity but not the size of the vector besides, you don't need to calculate the position of "past the end" just write this [code] std::sort(A.begin(), … |
The End.