Questions tagged [tr1]

TR1 - C++ Technical Report 1, proposed extensions to the C++ standard library

The Technical Report on C++ Library Extensions (a.k.a ISO/IEC TR 19768) defined a number of new library components for C++, many taken from the Boost project. Nearly all the components in TR1 were included in the C++ 2011 standard.

232 questions
9
votes
1 answer

Can tr1::function swallow return values?

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() {…
Chris
  • 103
  • 3
9
votes
3 answers

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

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"…
Evan Teran
  • 87,561
  • 32
  • 179
  • 238
9
votes
3 answers

shared_ptr in std::tr1

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…
user34537
9
votes
1 answer

The difference between python dict and tr1::unordered_map in C++

I have a question related to understanding of how python dictionaries work. I remember reading somewhere strings in python are immutable to allow hashing, and it is the same reason why one cannot directly use lists as keys, i.e. the lists are…
none
9
votes
3 answers

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

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…
Steve
  • 11,763
  • 15
  • 70
  • 103
9
votes
4 answers

C++ TR1: how to use the normal_distribution?

I'm trying to use the C++ STD TechnicalReport1 extensions to generate numbers following a normal distribution, but this code (adapted from this article): mt19937 eng; eng.seed(SEED); normal_distribution dist; // XXX if I use the one…
puccio
  • 3,054
  • 8
  • 29
  • 20
8
votes
2 answers

Comparing std::function<>

Is it possible to somehow compare two std::tr1::function<> objects? What if I have a collection of function objects and want to add and remove event handlers? Adding is trivial, but finding the one to be removed seems to be…
Marc Andreson
  • 3,405
  • 5
  • 35
  • 51
8
votes
3 answers

Using C++ classes like function that may be defined in several different locations

Between C++0x, C++03 TR1 and boost some things like function and bind can be defined in 3 different places depending on the compiler, eg for VC pre VC9 feature pack you have the boost versions, then you get them in but in the std::tr1:: namespace,…
Fire Lancer
  • 29,364
  • 31
  • 116
  • 182
8
votes
1 answer

On the initialization of std::array

Let's say you have a c++0x std::array member of a template class and you want to initialize it by means of a constructor that takes a couple of iterators: template class Test { public: template
Nicola Bonelli
  • 8,101
  • 4
  • 26
  • 35
8
votes
4 answers

Determine compile-time existence of include files in C++

I'm trying to write some portable C++ library code that will initially rely on Boost.Regex, and then move to TR1 as compilers support it, and eventually to the C++0x specification after things get moved from the std::tr1 namespace to std. Here is…
Zac
  • 876
  • 1
  • 8
  • 18
8
votes
2 answers

How to use tr1 with Visual Studio 2010 (tr1::function)?

How does one start using the tr1 features of Visual Studio 2010? For a more specific case, I require the std::tr1::function. I tried including #include which reports as missing, while #include includes fine, but when I…
Speed
  • 1,424
  • 1
  • 16
  • 24
7
votes
3 answers

Why some include files only reside in tr1?

When I try to include things like it fails and says the file doesn't exist, while when I try to include it works. however, the include files that are present also in c++03 are found, and are c++11 (like
Daniel
  • 30,896
  • 18
  • 85
  • 139
7
votes
1 answer

Is there a match_partial in C++11 Regular Expressions?

I read through n1429 with the section The algorithms regex_match and regex_search both support a feature not commonly seen in regular expression libraries: a partial match. When the flag std::regex_constants::match_partial is set in the flags…
towi
  • 21,587
  • 28
  • 106
  • 187
7
votes
1 answer

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

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…
user159335
7
votes
2 answers

R-value inserts don't work for unordered_map

I'm using the latest available GCC build from repository. I decided to use it because some additional C++0x features. However now I stuck with something what supposes to work - I want to add new element to map via r-value. Simplified code, which…
Goofy
  • 5,187
  • 5
  • 40
  • 56
1 2
3
15 16