Search Results

Search found 397 results on 16 pages for 'c 0x'.

Page 1/16 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • When will YOU adopt C++0x?

    - by HighCommander4
    I'm particularly looking for input from managers of ongoing C++ projects: Have you already adopted C++0x? If so, what has your experience been like? If you haven't adopted C++0x yet, are you planning to? If so, what is your timeline (in rough terms)? Are there any obstacles that are holding you back from adopting C++0x? Perhaps you are waiting for your favourite compiler or IDE to catch up? For managers of open source projects: are you afraid that adopting C++0x will mean less developers who are willing/able to contribute because they don't know the new features? Or, on the other hand, do you think most developers have been eagerly awaiting C++0x, and and will jump at the opportunity to use it? Do you think C++0x is stable enough to be adopted by a large project?

    Read the article

  • How to interrupt a waiting C++0x thread?

    - by doublep
    I'm considering to use C++0x threads in my application instead of Boost threads. However, I'm not sure how to reimplement what I have with standard C++0x threads since they don't seem to have an interrupt() method. My current setup is: a master thread that manages work; several worker threads that carry out master's commands. Workers call wait() on at least two different condition variables. Master has a "timed out" state: in this case it tells all workers to stop and give whatever result they got by then. With Boost threads master just uses interrupt_all() on a thread group, which causes workers to stop waiting. In case they are not waiting at the moment, master also sets a bool flag which workers check periodically. However, in C++0x std::thread I don't see any replacement for interrupt(). Do I miss something? If not, how can I implement the above scheme so that workers cannot just sleep forever?

    Read the article

  • g++ and c++0x specification support

    - by SepiDev
    although it's been said that the support for c++0x new features in g++ are in experimental mode, many gcc developer claimed that you can use most of the new features in your codes and get the program to work. but when I try to compile this simple program it results in segmentation fault. Why? #include <thread> #include <iostream> void my_thread_func() { std::cout<<"hello"<<std::endl; } int main() { std::thread t(my_thread_func); t.join(); } g++ -std=c++0x -Wall -o run main.cc

    Read the article

  • Should I use C++0x Features Now?

    - by svu2g
    With the official release of VS 2010, is it safe for me to start using the partially-implemented C++0x feature set in my new code? The features that are of interest to me right now are both implemented by VC++ 2010 and recent versions of GCC. These are the only two that I have to support. In terms of the "safety" mentioned in the first sentence: can I start using these features (e.g., lambda functions) and still be guaranteed that my code will compile in 10 years on a compiler that properly conforms to C++0x when it is officially released? I guess I'm asking if there is any chance that VC++ 2010 or GCC will end up like VC++ 6; it was released before the language was officially standardized and consequently allowed grossly ill-formed code to compile. After all, Microsoft does say that "10 is the new 6". ;)

    Read the article

  • C++0x optimizing compiler quality

    - by aaa
    hello. I do some heavy numbercrunching and for me floating-point performance is very important. I like performance of Intel compiler very much and quite content with quality of assembly it produces. I am thinking at some point to try C++0x mainly for sugar parts, like auto, initializer list, etc, but also lambdas. at this point I use those features in regular C++ by the means of boost. How good of assembly code do compilers C++0x generate? specifically Intel and gcc compilers. Do they produce SSE code? is performance comparable to C++? are there any benchmarks? My Google search did not reveal much. Thank you.

    Read the article

  • C# style Action<T>, Func<T,T>, etc in C++0x

    - by Austin Hyde
    C# has generic function types such as Action<T> or Func<T,U,V,...> With the advent of C++0x and the ability to have template typedef's and variadic template parameters, it seems this should be possible. The obvious solution to me would be this: template <typename T> using Action<T> = void (*)(T); however, this does not accommodate for functors or C++0x lambdas, and beyond that, does not compile with the error "expected unqualified-id before 'using'" My next attempt was to perhaps use boost::function: template <typename T> using Action<T> = boost::function<void (T)>; This doesn't compile either, for the same reason. My only other idea would be STL style template arguments: template <typename T, typename Action> void foo(T value, Action f) { f(value); } But this doesn't provide a strongly typed solution, and is only relevant inside the templated function. Now, I will be the first to admit that I am not the C++ wiz I prefer to think I am, so it's very possible there is an obvious solution I'm not seeing. Is it possible to have C# style generic function types in C++?

    Read the article

  • How are you using C++0x today? [closed]

    - by Roger Pate
    This is a question in two parts, the first is the most important and concerns now: Are you following the design and evolution of C++0x? What blogs, newsgroups, committee papers, and other resources do you follow? Even where you're not using any new features, how have they affected your current choices? What new features are you using now, either in production or otherwise? The second part is a follow-up, concerning the new standard once it is final: Do you expect to use it immediately? What are you doing to prepare for C++0x, other than as listed for the previous questions? Obviously, compiler support must be there, but there's still co-workers, ancillary tools, and other factors to consider. What will most affect your adoption? Edit: The original really was too argumentative; however, I'm still interested in the underlying question, so I've tried to clean it up and hopefully make it acceptable. This seems a much better avenue than duplicating—even though some answers responded to the argumentative tone, they still apply to the extent that they addressed the questions, and all answers are community property to be cleaned up as appropriate, too.

    Read the article

  • Are you using C++0x today? [closed]

    - by Roger Pate
    This is a question in two parts, the first is the most important and concerns now: Are you following the design and evolution of C++0x? What blogs, newsgroups, committee papers, and other resources do you follow? Even where you're not using any new features, how have they affected your current choices? What new features are you using now, either in production or otherwise? The second part is a follow-up, concerning the new standard once it is final: Do you expect to use it immediately? What are you doing to prepare for C++0x, other than as listed for the previous questions? Obviously, compiler support must be there, but there's still co-workers, ancillary tools, and other factors to consider. What will most affect your adoption? Edit: The original really was too argumentative; however, I'm still interested in the underlying question, so I've tried to clean it up and hopefully make it acceptable. This seems a much better avenue than duplicating—even though some answers responded to the argumentative tone, they still apply to the extent that they addressed the questions, and all answers are community property to be cleaned up as appropriate, too.

    Read the article

  • Omit return type in C++0x

    - by Clinton
    I've recently found myself using the following macro with gcc 4.5 in C++0x mode: #define RETURN(x) -> decltype(x) { return x; } And writing functions like this: template <class T> auto f(T&& x) RETURN (( g(h(std::forward<T>(x))) )) I've been doing this to avoid the inconvenience having to effectively write the function body twice, and having keep changes in the body and the return type in sync (which in my opinion is a disaster waiting to happen). The problem is that this technique only works on one line functions. So when I have something like this (convoluted example): template <class T> auto f(T&& x) -> ... { auto y1 = f(x); auto y2 = h(y1, g1(x)); auto y3 = h(y1, g2(x)); if (y1) { ++y3; } return h2(y2, y3); } Then I have to put something horrible in the return type. Furthermore, whenever I update the function, I'll need to change the return type, and if I don't change it correctly, I'll get a compile error if I'm lucky, or a runtime bug in the worse case. Having to copy and paste changes to two locations and keep them in sync I feel is not good practice. And I can't think of a situation where I'd want an implicit cast on return instead of an explicit cast. Surely there is a way to ask the compiler to deduce this information. What is the point of the compiler keeping it a secret? I thought C++0x was designed so such duplication would not be required.

    Read the article

  • Using deprecated binders and C++0x lambdas

    - by Sumant
    C++0x has deprecated the use of old binders such as bind1st and bind2nd in favor of generic std::bind. C++0x lambdas bind nicely with std::bind but they don't bind with classic bind1st and bind2nd because by default lambdas don't have nested typedefs such as argument_type, first_argument_type, second_argument_type, and result_type. So I thought std::function can serve as a standard way to bind lambdas to the old binders because it exposes the necessary typedefs. However, using std::function is hard to use in this context because it forces you to spell out the function-type while instantiating it. auto bound = std::bind1st(std::function<int (int, int)>([](int i, int j){ return i < j; }), 10); // hard to use auto bound = std::bind1st(std::make_function([](int i, int j){ return i < j; }), 10); // nice to have but does not compile. I could not find a convenient object generator for std::function. Something like std::make_fuction would be nice to have. Does such a thing exist? If not, is there any other better way of binding lamdas to the classic binders?

    Read the article

  • Why is C++0x's `noexcept` checked dynamically?

    - by rlbond
    I am curious about the rationale behind noexcept in the C++0x FCD. throw(X) was depreciated, but noexcept seems to do the same thing. Is there a reason that noexcept isn't checked at compile time? It seems that it would be better if these functions were checked statically that they only called throwing functions within a try block.

    Read the article

  • Undefined symbols for C++0x lambdas?

    - by Austin Hyde
    I was just poking around into some new stuff in C++0x, when I hit a stumbling block: #include <list> #include <cstdio> using namespace std; template <typename T,typename F> void ForEach (list<T> l, F f) { for (typename list<T>::iterator it=l.begin();it!=l.end();++it) f(*it); } int main() { int arr[] = {1,2,3,4,5,6}; list<int> l (arr,arr+6); ForEach(l,[](int x){printf("%d\n",x);}); } does not compile. I get a load of undefined symbol errors. Here's make's output: i386-apple-darwin9-gcc-4.5.0 -std=c++0x -I/usr/local/include -o func main.cpp Undefined symbols: "___cxa_rethrow", referenced from: std::_List_node<int>* std::list<int, std::allocator<int> >::_M_create_node<int const&>(int const&&&) in ccPxxPwU.o "operator new(unsigned long)", referenced from: __gnu_cxx::new_allocator<std::_List_node<int> >::allocate(unsigned long, void const*) in ccPxxPwU.o "___gxx_personality_v0", referenced from: ___gxx_personality_v0$non_lazy_ptr in ccPxxPwU.o "___cxa_begin_catch", referenced from: std::_List_node<int>* std::list<int, std::allocator<int> >::_M_create_node<int const&>(int const&&&) in ccPxxPwU.o "operator delete(void*)", referenced from: __gnu_cxx::new_allocator<std::_List_node<int> >::deallocate(std::_List_node<int>*, unsigned long) in ccPxxPwU.o "___cxa_end_catch", referenced from: std::_List_node<int>* std::list<int, std::allocator<int> >::_M_create_node<int const&>(int const&&&) in ccPxxPwU.o "std::__throw_bad_alloc()", referenced from: __gnu_cxx::new_allocator<std::_List_node<int> >::allocate(unsigned long, void const*) in ccPxxPwU.o "std::_List_node_base::_M_hook(std::_List_node_base*)", referenced from: void std::list<int, std::allocator<int> >::_M_insert<int const&>(std::_List_iterator<int>, int const&&&) in ccPxxPwU.o ld: symbol(s) not found collect2: ld returned 1 exit status make: *** [func] Error 1 Why is this not working?

    Read the article

  • C++0x thread interruption

    - by Nicola Bonelli
    According to the C++0x final draft, there's no way to request a thread to terminate. That said, if required we need to implement a do-it-yourself solution. In your opinion, what's the best solution? Designing your own cooperative 'interruption mechanism' or going native?

    Read the article

  • Specializing a template on a lambda in C++0x

    - by Tony A.
    I've written a traits class that lets me extract information about the arguments and type of a function or function object in C++0x (tested with gcc 4.5.0). The general case handles function objects: template <typename F> struct function_traits { template <typename R, typename... A> struct _internal { }; template <typename R, typename... A> struct _internal<R (F::*)(A...)> { // ... }; typedef typename _internal<decltype(&F::operator())>::<<nested types go here>>; }; Then I have a specialization for plain functions at global scope: template <typename R, typename... A> struct function_traits<R (*)(A...)> { // ... }; This works fine, I can pass a function into the template or a function object and it works properly: template <typename F> void foo(F f) { typename function_traits<F>::whatever ...; } int f(int x) { ... } foo(f); What if, instead of passing a function or function object into foo, I want to pass a lambda expression? foo([](int x) { ... }); The problem here is that neither specialization of function_traits<> applies. The C++0x draft says that the type of the expression is a "unique, unnamed, non-union class type". Demangling the result of calling typeid(...).name() on the expression gives me what appears to be gcc's internal naming convention for the lambda, main::{lambda(int)#1}, not something that syntactically represents a C++ typename. In short, is there anything I can put into the template here: template <typename R, typename... A> struct function_traits<????> { ... } that will allow this traits class to accept a lambda expression?

    Read the article

  • Transition to C++0x from C++98

    - by Paul Nathan
    As someone who hasn't followed the C++0x - now C++1x - story and developments closely, I am considering that it is nearing the time when I need to come up to speed with the 'released' version. I also am not really interested in looking over the standard immediately. Therefore: What resources are there that give the "effective changelog" between language versions? What books/articles are there that probe into the use of the new features? (marked as community wiki, if there are other good questions that relate to the transition, put them up)

    Read the article

  • c++0x, std::thread error (thread not member of std)

    - by luis
    Hello I compiled & installed gcc4.4 using macports. When I try to compile using - g++ -g -Wall -ansi -pthread -std=c++0x main.cpp...: #include ... std::thread t(handle); t.join(); .... The compiler returns: cserver.cpp: In member function 'int CServer::run()': cserver.cpp:48: error: 'thread' is not a member of 'std' cserver.cpp:48: error: expected ';' before 't' cserver.cpp:49: error: 't' was not declared in this scope But std::cout <<... compiles fine.. Can anyone help me? Thanks! Luis

    Read the article

  • C++0x regex in GCC

    - by rwallace
    The following code: #include <regex> using namespace std; (snippage) regex_search(s, m, re); works in Microsoft C++, but GCC 4.4.3 gives the following error message: /usr/include/c++/4.4/tr1_impl/regex:2255: warning: inline function ‘bool std::regex_search(_Bi_iter, _Bi_iter, std::match_results<_Bi_iter, _Allocator&, const std::basic_regex<_Ch_type, _Rx_traits&, std::regex_constants::match_flag_type) [with _Bi_iter = __gnu_cxx::__normal_iterator, std::allocator , _Allocator = std::allocator, std::allocator , _Ch_type = char, _Rx_traits = std::regex_traits]’ used but never defined Of course it wouldn't surprise me if regex were simply one of the C++0x features still on the to-do list for GCC, but what I'm scratching my head over is, in that case, why does it happily take the include directive, variable declarations etc. and only trip over the function call (which it even seems to understand). Is there something I'm missing?

    Read the article

  • How to use autoconf with C++0x features

    - by themis
    What are the best practices for using autoconf in conjunction with shared_ptr and other TR1/BOOST C++0x templates so as to maximize portability and maintainability? With autoconf I can determine whether shared_ptr is available as std::tr1::shared_ptr and/or boost::shared_ptr. Given that the same feature has two different names, I have the following questions: In the code, how should shared_ptr be referenced? Should std::tr1::shared_ptr be preferred over boost::shared_ptr? For the first, the code is currently using preprocessor conditionals allowing non-qualified references to shared_ptr, a la #if HAVE_STD_TR1_SHARED_PTR using std::tr1::shared_ptr; #elif HAVE_BOOST_SHARED_PTR using boost::shared_ptr; #else #error "No definition for shared_ptr found" #endif Second, the code uses std::tr1:: over boost:: to minimize dependencies on external libraries (even if the the libraries are widely used). Are these two solutions common? Are there better ones?

    Read the article

  • Closure and nested lambdas in C++0x

    - by DanDan
    Using C++0x, how do I capture a variable when I have a lambda within a lambda? For example: std::vector<int> c1; int v = 10; <--- I want to capture this variable std::for_each( c1.begin(), c1.end(), [v](int num) <--- This is fine... { std::vector<int> c2; std::for_each( c2.begin(), c2.end(), [v](int num) <--- error on this line, how do I recapture v? { // Do something }); });

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >