tr1

OS-X support for std::tr1

蓝咒 提交于 2019-12-23 08:54:29
问题 What is the current support for tr1 or the new C++0x on the Mac I know that the gcc supplied with XCode is always a couple of versions behind that available from gcc.gnu.org so I was just wondering what the state of play for modern support was. For example do I need to download boost to use shared_ptr or can I get it from std::tr1? 回答1: OS X 10.6 ships with g++ 4.2.1 as well as g++ 4.0, but it should be straightforward to install your own build if you choose to. GNU tools are awesome for that

What will happen to namespace tr1 when c++ xx is approved?

十年热恋 提交于 2019-12-23 07:30:41
问题 I'm writing some stuff using the tr1 namespace in VS2008. What will happen when C++xx becomes ratified? Has this happened before with other C++ revisions? Will the tr1 stuff still work or will I have to change all of my include? I realize that I'm making the very large assumption that this ratification will someday occur. I know that most likely none of you work for MS or contribute to GCC, but if you have experience with these kinds of changes, I would appreciate the advice. 回答1: std::tr1

Assigning existing values to smart-ptrs?

倾然丶 夕夏残阳落幕 提交于 2019-12-23 07:30:09
问题 I am just learning about smart pointers, and I am having trouble assigning a pre-existing location of a variable to the standard library's shared pointer. For example, lets say you have an int x, which you do not know the value of. With normal pointers, I just did int* ptr; ptr = &x; I tried both that with shared pointers, and std::tr1::shared_ptr<int> ptr; ptr = std::make_shared<int> (&x) So i'm fairly lost as to how to do it. 回答1: You wouldn't (usually) make a smart pointer point to an

How to check for TR1 while compiling?

点点圈 提交于 2019-12-22 06:49:34
问题 We are programming a logging library that keeps itself in a .hpp file. We would like to include <tr1/unordered_map> (if the compiler supports TR1,) or the standard <map> otherwise. Is there a standard way of checking at compile time if tr1 is available or not? I was thinking that the same way that the " __cplusplus " define symbol is present, there could have been defined a " __cxx__tr1 " or something like that. I haven't seen that in the drafts for TR1, so I assume it is not present, but I

Can tr1::function swallow return values?

血红的双手。 提交于 2019-12-22 04:01:01
问题 The boost::function FAQ item 3 specifically addresses the scenario I am interested in: Why are there workarounds for void returns? C++ allows them! Void returns are permitted by the C++ standard, as in this code snippet: void f(); void g() { return f(); } This is a valid usage of boost::function because void returns are not used. With void returns, we would attempting to compile ill-formed code similar to: int f(); void g() { return f(); } In essence, not using void returns allows boost:

shared_ptr in std::tr1

柔情痞子 提交于 2019-12-21 09:04:04
问题 I am working on a platform with a gcc compiler however boost cannot compile on it. I am wondering what is the proper way to include the shared_ptr in std:tr1 on gcc? the file i looked in said not to include it directly, from what i can tell no other file includes it either :| 回答1: In G++ 4.3 , #include <tr1/memory> should do the trick. You'll find shared_ptr at std::tr1::shared_ptr . 回答2: Boost itself has the answer. 回答3: Boost can not compile on it? Most of the boost library doesn't need to

shared_ptr in std::tr1

主宰稳场 提交于 2019-12-21 09:03:47
问题 I am working on a platform with a gcc compiler however boost cannot compile on it. I am wondering what is the proper way to include the shared_ptr in std:tr1 on gcc? the file i looked in said not to include it directly, from what i can tell no other file includes it either :| 回答1: In G++ 4.3 , #include <tr1/memory> should do the trick. You'll find shared_ptr at std::tr1::shared_ptr . 回答2: Boost itself has the answer. 回答3: Boost can not compile on it? Most of the boost library doesn't need to

std::regex equivalent of '/g' global modifier

。_饼干妹妹 提交于 2019-12-21 02:41:41
问题 In Perl, I can do this: $text = '1747239'; @matches = ($text =~ m/(\d)/g); # @matches now contains ('1', '7', '4', '7', '2', '3', '9') Using C++ regex matching, what's the best way to replicate this behaviour so that I get a match set including all the matches? I have this at the moment:- compiledRegex = std::regex(regex, std::tr1::regex_constants::extended); regex_search(text, results, compiledRegex); int count = results.size(); // Alloc pointer array based on count * sizeof(mystruct). for (

returning a 'pointer' which is required to be held by a smart pointer

别等时光非礼了梦想. 提交于 2019-12-20 09:44:07
问题 I have a project which I would like to make more use of smart pointers. Overall, I have been successful in this goal. However, I've come across one things which I'm not sure what the "best practice" is. Basically I would like to return a "pointer" from a function, but require that the user hold it in a smart pointer. Not only that, I don't want to mandate a particular smart pointer (shared vs. scoped). The problem is mostly that there doesn't seem be to a proper way to upgrade a scoped_ptr to

error while using regex_replace function from <tr1/regex>

孤人 提交于 2019-12-20 02:37:15
问题 #include <string> #include <tr1/regex> #include "TextProcessing.h" const std::string URL_PATTERN("((http://)[-a-zA-Z0-9@:%_\\+.~#?&//=]+)"); const std::string REPLACEMENT("<a href=\"$&\"\">$&</a>"); std::string textprocessing::processLinks(const std::string & text) { // essentially the same regex as in the previous example, but using a dynamic regex std::tr1::regex url(URL_PATTERN); // As in Perl, $& is a reference to the sub-string that matched the regex return std::tr1::regex_replace(text,