Search Results

Search found 1803 results on 73 pages for 'boost dataflow'.

Page 25/73 | < Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >

  • typedef declaration syntax

    - by mt_serg
    Some days ago I looked at boost sources and found interesting typedef. There is a code from "boost\detail\none_t.hpp": namespace boost { namespace detail { struct none_helper{}; typedef int none_helper::*none_t ; } // namespace detail } // namespace boost I didn't see syntax like that earlier and can't explain the sense of that. This typedef introduces name "none_t" as pointer to int in boost::detail namespace. What the syntax is? And what difference between "typedef int none_helper::*none_t" and for example "typedef int *none_t" ?

    Read the article

  • SOLR - Boost function (bf) to increase score of documents whose date is closest to NOW

    - by Mechanic
    Hi all, I have a solr instance containing documents which have a 'startTime' field ranging from last month to a year from now. I'd like to add a boost query/function to boost the scores of documents whose startTime field is close to the current time. So far I have seen a lot of examples which use rord to add boosts to documents whom are newer but I have never seen an example of something like this. Can anyone tell me how to do it please? Thanks

    Read the article

  • To find a determinate of Matrix using Boost library in c++

    - by user314097
    Hi, I' am required to convert a MATLAB function into C++, and this requires me to find determinate of a matrix. I was told that use of BOOST library would make my job easier. I went through the documentation of BOOST Library, but couldn't find much info about the same. If anyone could give a template for the above operation, It would be of lot of help and would be greatly appreciated. Thanks Regards

    Read the article

  • C++ Multithreading on Unix

    - by Roger
    I have two related questions: 1) Are there any good books for multithreading in C++, especially now that C++11 contains multithreading in the standard library? 2) I have the Wrox Programming on Unix book (1000 pages fat red one) and within it, it uses the Unix Thread class. How does this code relate to boost and the C++11 multithreading libraries? Is it better/worse/just specific to Unix etc? Is the performance the same?

    Read the article

  • Find version of development library from command line?

    - by mathematician1975
    I installed the c++ boost development libraries using Ubuntu software centre. The problem is that it was quite a long time ago and I cannot remember where they are installed nor what version they were. Is there anything I can do from the command line that will tell me what version(s) I have installed on my system?? I know I can do things like gcc -v to get version of an application but is there a similar thing available for libraries? I am using ubuntu 12.04

    Read the article

  • undefined reference to `main' collect2: ld returned 1 exit status

    - by sobingt
    I am working on this QT project and i am making test cases for my project. Here is a small test case #include <QApplication> #include <QPalette> #include <QPixmap> #include <QSplashScreen> #include <qthread.h> #define BOOST_TEST_MAIN #include <boost/test/unit_test.hpp> #include <boost/make_shared.hpp> # include <boost/thread.hpp> #include "MainWindow.h" namespace { const std::string dbname = "Project.db"; struct SongFixture { SongFixture(const std::string &fixturePath) { // Create the Master file Master::creator(); // Create/open file std::pair<int, SQLiteDbPtr> result = open( dbname, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0); if (result.first != SQLITE_OK) { throw SQLiteError(result.first, sqlite3_errmsg(result.second.get())); } SQLiteDbPtr &spDb = result.second; // Execute all the SQL from the fixture file execSQLFromFile(spDb, fixturePath); } }; std::auto_ptr<SongFixture> pf; } class I : public QThread { public: static void sleep(unsigned long secs) { QThread::sleep(secs); } }; void free_test_function() { BOOST_CHECK(true ); } test_suite* init_unit_test_suite(int argc, char *argv[]) { // Create a fixture for the peer: // Manage fixture creation manually instead of using // BOOST_FIXTURE_TEST_CASE because the fixture depends on runtime args. std::ostringstream fixturePathSS; fixturePathSS << PROJECT_DIR << "/test/songs_fixture.sql"; std::string fixturePath = fixturePathSS.str(); pf.reset(new SongFixture(fixturePath)); QApplication app(argc, argv); MainWindow window("artists"); window.show(); framework::master_test_suite().add( BOOST_TEST_CASE( &free_test_function )); return app.exec(); } Well i am getting any error /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/crt1.o: In function _start': (.text+0x20): undefined reference tomain' collect2: ld returned 1 exit status pls help me you have a lead..thankz I tired adding #define BOOST_TEST_MAIN then i get ../test/UI/main.cpp: In function ‘boost::unit_test::test_suite* init_unit_test_suite(int, char**)’: ../test/UI/main.cpp:75:31: error: redefinition of ‘boost::unit_test::test_suite* init_unit_test_suite(int, char**)’ /usr/local/include/boost/test/unit_test_suite.hpp:223:1: error: ‘boost::unit_test::test_suite* init_unit_test_suite(int, char**)’ previously defined here Well the program is working in Windows but in Linux the above mention problem is observed

    Read the article

  • why BOOST_FOREACH cannot handle const boost::ptr_map?

    - by psaghelyi
    void main() { typedef boost::ptr_map<int, char> MyMap; MyMap mymap; mymap[1] = 'a'; mymap[2] = 'b'; mymap[3] = 'c'; BOOST_FOREACH(MyMap::value_type value, mymap) { std::cout << value.first << " " << value.second << std::endl; } MyMap const & const_mymap = mymap; BOOST_FOREACH(MyMap::value_type value, const_mymap) { std::cout << value.first << " " << value.second << std::endl; } } The following error message comes from GCC at the second BOOST_FOREACH error: conversion from 'boost::ptr_container_detail::ref_pair<int, const char* const>' to non-scalar type 'boost::ptr_container_detail::ref_pair<int, char* const>' requested I reckon that this is the weakness of the pointer container's ref_pair...

    Read the article

  • Class member functions instantiated by traits

    - by Jive Dadson
    I am reluctant to say I can't figure this out, but I can't figure this out. I've googled and searched Stack Overflow, and come up empty. The abstract, and possibly overly vague form of the question is, how can I use the traits-pattern to instantiate non-virtual member functions? The question came up while modernizing a set of multivariate function optimizers that I wrote more than 10 years ago. The optimizers all operate by selecting a straight-line path through the parameter space away from the current best point (the "update"), then finding a better point on that line (the "line search"), then testing for the "done" condition, and if not done, iterating. There are different methods for doing the update, the line-search, and conceivably for the done test, and other things. Mix and match. Different update formulae require different state-variable data. For example, the LMQN update requires a vector, and the BFGS update requires a matrix. If evaluating gradients is cheap, the line-search should do so. If not, it should use function evaluations only. Some methods require more accurate line-searches than others. Those are just some examples. The original version instantiates several of the combinations by means of virtual functions. Some traits are selected by setting mode bits that are tested at runtime. Yuck. It would be trivial to define the traits with #define's and the member functions with #ifdef's and macros. But that's so twenty years ago. It bugs me that I cannot figure out a whiz-bang modern way. If there were only one trait that varied, I could use the curiously recurring template pattern. But I see no way to extend that to arbitrary combinations of traits. I tried doing it using boost::enable_if, etc.. The specialized state information was easy. I managed to get the functions done, but only by resorting to non-friend external functions that have the this-pointer as a parameter. I never even figured out how to make the functions friends, much less member functions. The compiler (VC++ 2008) always complained that things didn't match. I would yell, "SFINAE, you moron!" but the moron is probably me. Perhaps tag-dispatch is the key. I haven't gotten very deeply into that. Surely it's possible, right? If so, what is best practice? UPDATE: Here's another try at explaining it. I want the user to be able to fill out an order (manifest) for a custom optimizer, something like ordering off of a Chinese menu - one from column A, one from column B, etc.. Waiter, from column A (updaters), I'll have the BFGS update with Cholesky-decompositon sauce. From column B (line-searchers), I'll have the cubic interpolation line-search with an eta of 0.4 and a rho of 1e-4, please. Etc... UPDATE: Okay, okay. Here's the playing-around that I've done. I offer it reluctantly, because I suspect it's a completely wrong-headed approach. It runs okay under vc++ 2008. #include <boost/utility.hpp> #include <boost/type_traits/integral_constant.hpp> namespace dj { struct CBFGS { void bar() {printf("CBFGS::bar %d\n", data);} CBFGS(): data(1234){} int data; }; template<class T> struct is_CBFGS: boost::false_type{}; template<> struct is_CBFGS<CBFGS>: boost::true_type{}; struct LMQN {LMQN(): data(54.321){} void bar() {printf("LMQN::bar %lf\n", data);} double data; }; template<class T> struct is_LMQN: boost::false_type{}; template<> struct is_LMQN<LMQN> : boost::true_type{}; struct default_optimizer_traits { typedef CBFGS update_type; }; template<class traits> class Optimizer; template<class traits> void foo(typename boost::enable_if<is_LMQN<typename traits::update_type>, Optimizer<traits> >::type& self) { printf(" LMQN %lf\n", self.data); } template<class traits> void foo(typename boost::enable_if<is_CBFGS<typename traits::update_type>, Optimizer<traits> >::type& self) { printf("CBFGS %d\n", self.data); } template<class traits = default_optimizer_traits> class Optimizer{ friend typename traits::update_type; //friend void dj::foo<traits>(typename Optimizer<traits> & self); // How? public: //void foo(void); // How??? void foo() { dj::foo<traits>(*this); } void bar() { data.bar(); } //protected: // How? typedef typename traits::update_type update_type; update_type data; }; } // namespace dj int main_() { dj::Optimizer<> opt; opt.foo(); opt.bar(); std::getchar(); return 0; }

    Read the article

  • Boost.MultiIndex: How to make an effective set intersection?

    - by Arman
    Hello, assume that we have a data1 and data2. How can I intersect them with std::set_intersect()? struct pID { int ID; unsigned int IDf;// postition in the file pID(int id,const unsigned int idf):ID(id),IDf(idf){} bool operator<(const pID& p)const { return ID<p.ID;} }; struct ID{}; struct IDf{}; typedef multi_index_container< pID, indexed_by< ordered_unique< tag<IDf>, BOOST_MULTI_INDEX_MEMBER(pID,unsigned int,IDf)>, ordered_non_unique< tag<ID>,BOOST_MULTI_INDEX_MEMBER(pID,int,ID)> > > pID_set; ID_set data1, data2; Load(data1); Load(data2); pID_set::index<ID>::type& L1_ID_index=L1.data.get<ID>(); pID_set::index<ID>::type& L2_ID_index=L2.data.get<ID>(); // How do I use set_intersect? Kind regards, Arman.

    Read the article

  • How to write rule for ICU genrb and pkgdata for boost-build?

    - by sandy
    jamroot.jam rule genrb ( sources + : requirements * ) # create *.res files in binary directory { local result ; for local r in $(sources) { res $(r:B) : $(r) ; } } res.jam type.register RES : res ; type.register TXT : txt ; generators.register-standard res.resource : TXT : RES ; actions resource { $(icu_home)\bin64\genrb "-d$(<:D)" "$()" } I need to run pkgdata with parameters: pkgdata [-options] [-] [packageFile] packageFile is a text file containing the list of res-files to package.

    Read the article

  • How might I assume a "default value" when parsing using boost::spirit?

    - by tJener
    Let's say I have a grammar defined to something like: a b c d where c, and d are optional and default to 14 if not given. Can I get it to automatically return the 14 if the value isn't given? The closest I've come is like the following: qi::rule<Iterator, std::vector<int>(), ascii::space_type> some_rule; some_rule %= >> int_ >> int_ >> -int_ >> -int_; // ... some_other_rule = some_rule[&some_callback_for_int_vectors]; which will then get 0 for the optional values that didn't show up (I believe). I then change consecutive 0s at the end into 14. Not only is this horribly wrong, but its also just not elegant. Is there a better way to do this?

    Read the article

  • Why can't I extract a C++ type from a Python type using boost::python::extractor?

    - by Robin
    I've wrapped a C++ class using Py++ and everything is working great in Python. I can instantiate the c++ class, call methods, etc. I'm now trying to embed some Python into a C++ application. This is also working fine for the most-part. I can call functions on a Python module, get return values, etc. The python code I'm calling returns one of the classes that I wrapped: import _myextension as myext def run_script(arg): my_cpp_class = myext.MyClass() return my_cpp_class I'm calling this function from C++ like this: // ... excluding error checking, ref counting, etc. for brevity ... PyObject *pModule, *pFunc, *pArgs, *pReturnValue; Py_Initialize(); pModule = PyImport_Import(PyString_FromString("cpp_interface")); pFunc = PyObject_GetAttrString(pModule, "run_script"); pArgs = PyTuple_New(1); PyTuple_SetItem(pArgs, 0, PyString_FromString("an arg")); pReturnValue = PyObject_CallObject(pFunc, pArgs); bp::extract< MyClass& > extractor(pReturnValue); // PROBLEM IS HERE if (extractor.check()) { // This check is always false MyClass& cls = extractor(); } The problem is the extractor never actually extracts/converts the PyObject* to MyClass (i.e. extractor.check() is always false). According to the docs this is the correct way to extract a wrapped C++ class. I've tried returning basic data types (ints/floats/dicts) from the Python function and all of them are extracted properly. Is there something I'm missing? Is there another way to get the data and cast to MyClass?

    Read the article

  • [boost::filesystem] performance: is it better to read all files once, or use b::fs functions over an

    - by rubenvb
    I'm conflicted between a "read once, use memory+pointers to files" and a "read when necessary" approach. The latter is of course much easier (no additional classes needed to store the whole dir structure), but IMO it is slower? A little clarification: I'm writing a simple build system, that read a project file, checks if all files are present, and runs some compile steps. The file tree is static, so the first option doesn't need to be very dynamic and only needs to be built once every time the program is run. Thanks

    Read the article

  • fatal error LNK1104: cannot open file 'libboost_system-vc90-mt-gd-1_43.lib'

    - by Poni
    Made a new project, added main.cpp and wrote the code at this URL: http://www.boost.org/doc/libs/1_43_0/doc/html/boost_asio/example/echo/async_tcp_echo_server.cpp Also, added the appropriate include path. What's next?!?!! It seems like a darn mystery to build a boost code! Been digging on it for more than 10 hours. Can anyone give a straightforward answer on how to build the boost library from the code under windows, VC9? God bless you all.

    Read the article

  • Class member functions instantiated by traits [policies, actually]

    - by Jive Dadson
    I am reluctant to say I can't figure this out, but I can't figure this out. I've googled and searched Stack Overflow, and come up empty. The abstract, and possibly overly vague form of the question is, how can I use the traits-pattern to instantiate member functions? [Update: I used the wrong term here. It should be "policies" rather than "traits." Traits describe existing classes. Policies prescribe synthetic classes.] The question came up while modernizing a set of multivariate function optimizers that I wrote more than 10 years ago. The optimizers all operate by selecting a straight-line path through the parameter space away from the current best point (the "update"), then finding a better point on that line (the "line search"), then testing for the "done" condition, and if not done, iterating. There are different methods for doing the update, the line-search, and conceivably for the done test, and other things. Mix and match. Different update formulae require different state-variable data. For example, the LMQN update requires a vector, and the BFGS update requires a matrix. If evaluating gradients is cheap, the line-search should do so. If not, it should use function evaluations only. Some methods require more accurate line-searches than others. Those are just some examples. The original version instantiates several of the combinations by means of virtual functions. Some traits are selected by setting mode bits that are tested at runtime. Yuck. It would be trivial to define the traits with #define's and the member functions with #ifdef's and macros. But that's so twenty years ago. It bugs me that I cannot figure out a whiz-bang modern way. If there were only one trait that varied, I could use the curiously recurring template pattern. But I see no way to extend that to arbitrary combinations of traits. I tried doing it using boost::enable_if, etc.. The specialized state information was easy. I managed to get the functions done, but only by resorting to non-friend external functions that have the this-pointer as a parameter. I never even figured out how to make the functions friends, much less member functions. The compiler (VC++ 2008) always complained that things didn't match. I would yell, "SFINAE, you moron!" but the moron is probably me. Perhaps tag-dispatch is the key. I haven't gotten very deeply into that. Surely it's possible, right? If so, what is best practice? UPDATE: Here's another try at explaining it. I want the user to be able to fill out an order (manifest) for a custom optimizer, something like ordering off of a Chinese menu - one from column A, one from column B, etc.. Waiter, from column A (updaters), I'll have the BFGS update with Cholesky-decompositon sauce. From column B (line-searchers), I'll have the cubic interpolation line-search with an eta of 0.4 and a rho of 1e-4, please. Etc... UPDATE: Okay, okay. Here's the playing-around that I've done. I offer it reluctantly, because I suspect it's a completely wrong-headed approach. It runs okay under vc++ 2008. #include <boost/utility.hpp> #include <boost/type_traits/integral_constant.hpp> namespace dj { struct CBFGS { void bar() {printf("CBFGS::bar %d\n", data);} CBFGS(): data(1234){} int data; }; template<class T> struct is_CBFGS: boost::false_type{}; template<> struct is_CBFGS<CBFGS>: boost::true_type{}; struct LMQN {LMQN(): data(54.321){} void bar() {printf("LMQN::bar %lf\n", data);} double data; }; template<class T> struct is_LMQN: boost::false_type{}; template<> struct is_LMQN<LMQN> : boost::true_type{}; // "Order form" struct default_optimizer_traits { typedef CBFGS update_type; // Selection from column A - updaters }; template<class traits> class Optimizer; template<class traits> void foo(typename boost::enable_if<is_LMQN<typename traits::update_type>, Optimizer<traits> >::type& self) { printf(" LMQN %lf\n", self.data); } template<class traits> void foo(typename boost::enable_if<is_CBFGS<typename traits::update_type>, Optimizer<traits> >::type& self) { printf("CBFGS %d\n", self.data); } template<class traits = default_optimizer_traits> class Optimizer{ friend typename traits::update_type; //friend void dj::foo<traits>(typename Optimizer<traits> & self); // How? public: //void foo(void); // How??? void foo() { dj::foo<traits>(*this); } void bar() { data.bar(); } //protected: // How? typedef typename traits::update_type update_type; update_type data; }; } // namespace dj int main() { dj::Optimizer<> opt; opt.foo(); opt.bar(); std::getchar(); return 0; }

    Read the article

  • Libtool versioning of a library that depends on other libraries.

    - by Artyom
    Hello, I have a framework that uses Boost and CgiCC in the core application and in its interface. How should I version the library binary interface (a.k.a. libtool -version-info)? I have no problems tracking the changes in library itself when I make various changes. As it is clear for me how should I version. But... Both Boost and CgiCC libraries do not provide any backward compatible API/ABI and my library may be linked with quite arbitrary versions Boost and CgiCC so I can't provide any promise about the interfaces, so I can't really specify -version-info because even the same library compiled against different versions of Boost and CgiCC would not be compatible. So... What should I do? How should I version library? I know that I should not depend on Boost and CgiCC interfaces in first place, but this is what I get so far for existing stable version. This issue is addressed in next major release but I still have and want to maintain current release as it is very valuable.

    Read the article

  • Recommendations for a C++ polymorphic, seekable, binary I/O interface

    - by Trevor Robinson
    I've been using std::istream and ostream as a polymorphic interface for random-access binary I/O in C++, but it seems suboptimal in numerous ways: 64-bit seeks are non-portable and error-prone due to streampos/streamoff limitations; currently using boost/iostreams/positioning.hpp as a workaround, but it requires vigilance Missing operations such as truncating or extending a file (ala POSIX ftruncate) Inconsistency between concrete implementations; e.g. stringstream has independent get/put positions whereas filestream does not Inconsistency between platform implementations; e.g. behavior of seeking pass the end of a file or usage of failbit/badbit on errors Don't need all the formatting facilities of stream or possibly even the buffering of streambuf streambuf error reporting (i.e. exceptions vs. returning an error indicator) is supposedly implementation-dependent in practice I like the simplified interface provided by the Boost.Iostreams Device concept, but it's provided as function templates rather than a polymorphic class. (There is a device class, but it's not polymorphic and is just an implementation helper class not necessarily used by the supplied device implementations.) I'm primarily using large disk files, but I really want polymorphism so I can easily substitute alternate implementations (e.g. use stringstream instead of fstream for unit tests) without all the complexity and compile-time coupling of deep template instantiation. Does anyone have any recommendations of a standard approach to this? It seems like a common situation, so I don't want to invent my own interfaces unnecessarily. As an example, something like java.nio.FileChannel seems ideal. My best solution so far is to put a thin polymorphic layer on top of Boost.Iostreams devices. For example: class my_istream { public: virtual std::streampos seek(stream_offset off, std::ios_base::seekdir way) = 0; virtual std::streamsize read(char* s, std::streamsize n) = 0; virtual void close() = 0; }; template <class T> class boost_istream : public my_istream { public: boost_istream(const T& device) : m_device(device) { } virtual std::streampos seek(stream_offset off, std::ios_base::seekdir way) { return boost::iostreams::seek(m_device, off, way); } virtual std::streamsize read(char* s, std::streamsize n) { return boost::iostreams::read(m_device, s, n); } virtual void close() { boost::iostreams::close(m_device); } private: T m_device; };

    Read the article

  • Using static mutex in a class

    - by Dmitry Yudakov
    I have a class that I can have many instances of. Inside it creates and initializes some members from a 3rd party library (that use some global variables) and is not thread-safe. I thought about using static boost::mutex, that would be locked in my class constructor and destructor. Thus creating and destroying instances among my threads would be safe for the 3rd party members. class MyClass { static boost::mutex mx; // 3rd party library members public: MyClass(); ~MyClass(); }; MyClass::MyClass() { boost::mutex::scoped_lock scoped_lock(mx); // create and init 3rd party library stuff } MyClass::~MyClass() { boost::mutex::scoped_lock scoped_lock(mx); // destroy 3rd party library stuff } I cannot link because I receive error: undefined reference to `MyClass::mx` Do I need some special initialization of such static member? Is the whole conception of static mutex wrong?

    Read the article

  • Casting a container of shared_ptr

    - by Jamie Cook
    Hi all, I have a method void foo(list<shared_ptr<Base>>& myList); Which I'm trying to call with a two different types of lists, one of DerivedClass1 and one of DerivedClass2 list<shared_ptr<DerivedClass1>> myList1; foo(myList1); list<shared_ptr<DerivedClass2>> myList2; foo(myList2); However this obviously generates a compiler error error: a reference of type "std::list<boost::shared_ptr<Base>, std::allocator<boost::shared_ptr<Base>>> &" (not const-qualified) cannot be initialized with a value of type "std::list<boost::shared_ptr<DerivedClass1>, std::allocator<boost::shared_ptr<DerivedClass1>>>" Is there any easy way to cast a container of shared_ptr? Of alternate containers that can accomplish this?

    Read the article

  • C++: conjunction of binds?

    - by Helltone
    Suppose the following two functions: #include <iostream> #include <cstdlib> // atoi #include <cstring> // strcmp #include <boost/bind.hpp> bool match1(const char* a, const char* b) { return (strcmp(a, b) == 0); } bool match2(int a, const char* b) { return (atoi(b) == a); } Each of these functions takes two arguments, but can be transformed into a callable object that takes only one argument by using (std/boost)bind. Something along the lines of: boost::bind(match1, "a test"); boost::bind(match2, 42); I want to be able to obtain, from two functions like these that take one argument and return bool, a callable object that takes two arguments and returns the && of the bools. The type of the arguments is arbitrary. Something like an operator&& for functions that return bool.

    Read the article

< Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >