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
5
votes
7 answers

Are data structures an appropriate place for shared_ptr?

I'm in the process of implementing a binary tree in C++. Traditionally, I'd have a pointer to left and a pointer to right, but manual memory management typically ends in tears. Which leads me to my question... Are data structures an appropriate…
Gabriel Isenberg
  • 25,869
  • 4
  • 37
  • 58
5
votes
2 answers

TR1 from Boost or VC10 - Which one is better?

I'm currently migrating from Visual Studio 2008 to 2010. My software makes heavy use of Boost and its TR1 features. I now get a lot of compiler errors, because VC10 has it's own TR1 implementation. I know I can disable Microsoft's TR1 implementation…
Michel Krämer
  • 14,197
  • 5
  • 32
  • 32
5
votes
3 answers

tr1::mem_fn and tr1::bind: on const-correctness and overloading

What's wrong with the following snippet ? #include #include #include using namespace std::tr1::placeholders; struct abc { typedef void result_type; void hello(int) { std::cout <<…
Nicola Bonelli
  • 8,101
  • 4
  • 26
  • 35
5
votes
1 answer

Is it legal to place using tr1::shared_ptr in namespace std in header?

Is it legal and good programming style to use std::tr1::shared_ptr as std::shared_ptr placing using directive in corresponding header? Like this: namespace std { using tr1::shared_ptr; } I know that it's bad to pollute entire namespace but what…
cassini
  • 85
  • 5
5
votes
1 answer

How come cmath does not use templates and/or overloads

Many of the new functions brought in C++11 by TR1 have ugly C-like signatures. For instance, quoting Boost's TR1's documentation (http://www.boost.org/doc/libs/1_52_0/doc/html/boost_tr1/subject_list.html#boost_tr1.subject_list.special): //…
akim
  • 8,255
  • 3
  • 44
  • 60
4
votes
4 answers

construct two shared_ptr objects from the same pointer

I have a problem from "The C++ Standard Library Extensions": Exercise 6 I said in Section 2.4.2 that you shouldn't construct two shared_ptr objects from the same pointer. The danger is that both shared_ptr objects or their progeny will…
cnheying
  • 91
  • 5
4
votes
1 answer

Why std::shared_ptr control block need to hold a pointer to managed object with its correct type

I am looking at the shared_ptr implementation in the following post. One question that is not entirely clear to me is, why in addition to the pointer stored with T* type in shared_ptr class itself, author also needs to store the second copy of the…
4
votes
2 answers

Is there a better way to perform URL pattern matching in C++ than iteration?

I have a pattern matching routine that looks up values from a std::map based on the URL used to request the command. The URL mapping table is filled with values like: // Assume this->commands_ is defined elsewhere as std::map //…
JimEvans
  • 27,201
  • 7
  • 83
  • 108
4
votes
2 answers

What version of GNU GCC supports the TR1 extern templates?

What is the earliest GNU GCC (g++) version to support the TR1 extern templates? For example, is it already supported in version 4.0?
Frank
4
votes
2 answers

Defining a hash function in TR1 unordered_map inside a struct

According to this, it is possible to define an equality function in a TR1 unordered_map like this: #include using namespace std; using namespace std::tr1; struct foo{ ... bool operator==(const foo& b) const{ …
Alexandros
  • 3,044
  • 1
  • 23
  • 37
4
votes
2 answers

Allocation Target of std::aligned_storage (stack or heap?)

I've been trying to get my head around the TR1 addition known as aligned_storage. Whilst reading the following documents N2165, N3190 and N2140 I can't for the life of me see a statement where it clearly describes stack or heap nature of the memory…
Matthieu N.
4
votes
3 answers

Using C++0x TR1 random in a class, for low overhead

I'm using VC 2010 and trying to keep the overhead and duplicated code of certain functions low, by placing the random definitions in the constructor of each class instance, then calling as necessary from there. What I have now, simplified,…
SilverbackNet
  • 2,076
  • 17
  • 29
4
votes
3 answers

Using C++ Technical Report 1 (TR1) in VC++ 2010

How do I use a C++ TR1 library in visual c++ 2010?
user439547
  • 189
  • 1
  • 6
  • 12
4
votes
1 answer

Converting a lambda to a std::tr1::function

Using visual studio 2008 with the tr1 service pack and Intel C++ Compiler 11.1.071 [IA-32], this is related to my other question I'm attempting to write a functional map for c++ which would work somewhat like the ruby version strings = [2,4].map {…
Jamie Cook
  • 4,375
  • 3
  • 42
  • 53
4
votes
7 answers

I don't understand std::tr1::unordered_map

I need an associative container that makes me index a certain object through a string, but that also keeps the order of insertion, so I can look for a specific object by its name or just iterate on it and retrieve objects in the same order I…
martjno
  • 4,589
  • 5
  • 34
  • 31