• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

465 Neutral

About _moagstar_

  • Rank
  1. MacBook Pro Retina Display

    [quote name='tstrimple' timestamp='1341617570' post='4956529'] Oh, and the touchpad is simply amazing. It's one of those things that PC laptop manufacturers simply cannot get right. [/quote] As good as the mac touchpad is (much better than any PC laptop I tried) I still find it an immensly frustrating input device. Wireless mouse all the way for me (prefereably with 2 buttons!)
  2. C++ tools that are new to you

    [quote name='jwezorek' timestamp='1339092445' post='4947114'] Xerces = lightweight ... Seriously? [/quote] I would certainly agree with this, xerces is lot's of things, but lightweight is not one of them. The one redeming feature of xersec however is xml validation. However if you don't need that then I've found [url="http://code.google.com/p/pugixml/"]pugixml[/url] to be a more lightweight and easy to use alternative.
  3. C++ tools that are new to you

    One tool I've found particularly useful is [url="http://www.codesynthesis.com/products/xsd/"]codesynthesis xsd[/url] which can be used to transform xml schemas to c++ code for data binding. The main thing I use this for is for defining configuration files, although the use certainly not limited to that. I get xml parsing, validation and c++ representations of schemas for free. This means I can do all kinds of handy things such as automatic documentation generation using an xslt, and also editing the configurations becomes a breeze in a good xml editor (e.g. Visual Studio) which has auto-completion.
  4. Here is a really good introduction [url="http://www.ibm.com/developerworks/library/l-neural/"]http://www.ibm.com/developerworks/library/l-neural/[/url] The python library they use is also great for quickly getting started http://arctrix.com/nas/python/bpnn.py
  5. [quote name='Brother Bob' timestamp='1338231421' post='4944108'] In your concrete.cpp, just define the functions as normal outside-the-class member function definitions and instatiate the templates [/quote] If you are doing this as part of a static library I would say it's best to still put these function definitions in a seperate header file (or .ipp or .inl whatever takes your fancy) rather in the instantiating cpp (although as Brother Bob points out the extra class definition in your example code is redundant). This file can then be distributed with your normal headers. This way if you don't provide an explcit instantiation for a particular type, client code can still include the appropriate file and instantiate for that type, otherwise client code can only ever use the types you export. [CODE] // SomeStruct.hpp template <class T> struct SomeStruct { void func(); }; // SomeStruct.ipp template <class T> void SomeStruct<T>::func() { // code } // instantiation.cpp #include "SomeStruct.hpp" template class SomeStruct<int>; template class SomeStruct<double>; // client.cpp #include "SomeStruct.hpp" #include "SomeStruct.ipp" // explicit instantation for double not provided in SomeLib.lib SomeStruct<double> object; [/CODE]
  6. C++ compile-time template arg name?

    [quote name='Servant of the Lord' timestamp='1337957934' post='4943254'] If I was using 4.7, how would that be done? Something like this? [CODE]template <class Arg> constexpr const char *operator"" TypeName( const char * /* Ignore */) { return typeid(Arg).name(); }[/CODE] "Name of type is: " ## "dummyText"TypeName [/quote] Unfortunately this won't work... [quote] The declaration of a literal operator template shall have an empty parameterdeclaration-clause, and its template-parameter-list shall have a single template parameter that is a [b]non-type[/b] template parameter pack with element type char. [/quote] [url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2765.pdf"]http://www.open-std..../2008/n2765.pdf[/url] Even if there was some way of getting the type information into the user defined literal I just tried static_assert with a user defined literal in gcc 4.7 and the error message is empty, which is a shame. Proabably the best (and most portable) solution is to try and word your error message appropriately. [quote name='SiCrane' timestamp='1337953060' post='4943230'] gcc's __PRETTY_FUNCTION__ isn't a macro, it's a static const local variable. [/quote] That makes sense, since there's no way for the preprocessor to know what the function name will be.
  7. C++ compile-time template arg name?

    Which version of gcc are you using? I believe that user defined literals are supported from version 4.7 http://en.cppreference.com/w/cpp/language/user_literal It may be possible to parse the PRETTY_FUNCTION macro to get the text you require. However I havent tried this and am on a train at the moment so cannot test it myself.
  8. What SiCrane said, also note that you need to use a const_iterator since you are passing a const reference : [CODE] for(typename std::map<char, U>::const_iterator it = values.begin(); it != values.end(); it++) [/CODE]
  9. VS 2010 Compiler Crash

    Although it is a bug with the compiler that you don't get an appropriate error here, these messages are usually caused by something wrong in your code. This is the bug in your code: [CODE] template <class T> class fatalError { public: /* Doing qualified name look-up of a class that is being defined T* fatalError::getObject(int i){ return new T(i); } T *fatalError::getObject(const char *j){ return new T(j); } */ T* getObject(int i){ return new T(i); } T *getObject(const char *j){ return new T(j); } }; [/CODE] This compiles fine with the modifications above. EDIT : Sorry, I missed the "[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left][background=rgb(250, 251, 252)]On removing the fatalError:: part within the member function definitions" part[/background][/left][/size][/font][/color]
  10. Favorite rap/hip hop artist

    I'm not really into mainstream hip-hop to be honest but I like rjd2, I find it more melodic than a lot of hip-hop out there: [url="http://www.youtube.com/watch?v=0eS_hbeYpcI"]http://www.youtube.com/watch?v=0eS_hbeYpcI[/url] And although perhaps not technically hip-hop cocorosie have a certain something about the 'hip-hop-esque' style : [url="http://www.youtube.com/watch?v=vm1vjQZfDTE"]http://www.youtube.com/watch?v=vm1vjQZfDTE[/url]
  11. [quote name='Alpha_ProgDes' timestamp='1329941490' post='4915630'] As human beings, we think of this universe as the one and true universe. Everything we touch, feel, sense, interact with is real. But what happens, when the Matrix happens? Can one really argue that that isn't real? [/quote] [url="http://www.youtube.com/watch?v=BHihkRwisbE"]http://www.youtube.com/watch?v=BHihkRwisbE[/url] [quote]Everything you think you know is actually composed entirely of varying levels of belief[/quote] And that's my armchair philosophy done for the day.
  12. +1 for the _copy suffix. I would argue that it is the most idiomatic "c++" way of doing things, it's the approach taken by both the standard library and boost. As an example, take a look at the std::string member functions, the name of the function is the operation, and they are all mutating: [url="http://www.cplusplus.com/reference/string/string/replace/"]http://www.cplusplus.com/reference/string/string/replace/[/url] So I would expect the default behaviour of a function to be mutating, unless the name of the function specifies otherwise. I agree that the convenience of the copy version and the fact that it takes next to no work to implement make it worth the while. For some inspiration you might want to take a look at the boost string algorithms: [url="http://www.boost.org/doc/libs/1_48_0/doc/html/string_algo.html"]http://www.boost.org/doc/libs/1_48_0/doc/html/string_algo.html[/url]
  13. [quote name='kunos' timestamp='1327998678' post='4907923'] nightmares about circular references never cleaning up. [/quote] Use shared_ptr where the ownership of the object is [i]shared[/i], and weak_ptr for observers of an object and this should not be an issue.
  14. Assuming you are using C++, you can use some BOOST_PP trickery to do this while retaining type safety: [code] // log.h #include <iostream> #include <boost/preprocessor/library.hpp> #define MAKEARG(z, n, arg) << BOOST_PP_CAT(arg, n) #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, 8, "log_pp.h")) #include BOOST_PP_ITERATE() #undef MAKEARG [/code] [code] // log_pp.h template <BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), typename T)> inline void log(std::ostream& os, BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), const T, &arg)) { os BOOST_PP_REPEAT(BOOST_PP_ITERATION(), MAKEARG, arg); } [/code] [code] // log.cpp #include "log.h" int main(int argc, char* argv[]) { log(std::clog, "this", "is", "a", "test"); return 0; } [/code]
  15. A planet made of diamonds!

    [quote name='Sirisian' timestamp='1314396654' post='4854225'] If you travel with 1g acceleration you will get there in 88 years going extremely fast. [/quote] Even going "extremely fast", At some point you would hit the speed of light, and since nothing can travel faster than the speed of light the [i]minimum [/i]amount of time this journey could take is 4000 years. Unless of course you generate or find some kind of wormhole.
  • Advertisement