473,397 Members | 1,985 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

allocator: No such file or directory

Hi,

I'm following the example in "C++ Templates: The Complete Guide",
section 5.4 Template Template Parameters.

It's basics/stack8.hpp example has a statement of "#include <allocator>",
but I got an error for it.

$ cat -n allocator.cc
1 #include <allocator>
2
3 template< typename ALLOC = std::allocator<ELEM2
4 class c {};
5
6 template <typename T,
7 template <typename ELEM,
8 typename ALLOC = std::allocator<ELEM
9 class CONT = std::deque>
10 class Stack {
11 }
12
13 int main()
14 {
15 }

$ g++ -g allocator.cc -o allocator
allocator.cc:1:23: error: allocator: No such file or directory
[...]

How to fix the above allocator.cc so that it compiles fine?

Thanks.

FYI, why template template:

5.4 Template Template Parameters

It can be useful to allow a template parameter itself to be a class
template. Again, our stack class template can be used as an example. To
use a different internal container for stacks, the application programmer
has to specify the element type twice. Thus, to specify the type of the
internal container, you have to pass the type of the container and the
type of its elements again:

Stack<int,std::vector<int vStack; // integer stack that uses a vector

Using template template parameters allows you to declare the Stack class
template by specifying the type of the container without respecifying the
type of its elements:

stack<int,std::vectorvStack; // integer stack that uses a vector

To do this you must specify the second template parameter as a template
template parameter...
Aug 12 '08 #1
2 2453
On Tue, 12 Aug 2008 16:07:20 -0500, * Tong * wrote:
Hi,

I'm following the example in "C++ Templates: The Complete Guide",
section 5.4 Template Template Parameters.

It's basics/stack8.hpp example has a statement of "#include <allocator>",
but I got an error for it.

$ cat -n allocator.cc
1 #include <allocator>
2
3 template< typename ALLOC = std::allocator<ELEM2
4 class c {};
5
6 template <typename T,
7 template <typename ELEM,
8 typename ALLOC = std::allocator<ELEM
9 class CONT = std::deque>
10 class Stack {
11 }
12
13 int main()
14 {
15 }

$ g++ -g allocator.cc -o allocator
allocator.cc:1:23: error: allocator: No such file or directory
[...]

How to fix the above allocator.cc so that it compiles fine?

Thanks.
My g++:

$ g++ --version
g++ (GCC) 4.2.3 (Debian 4.2.3-1)
FYI, why template template:

5.4 Template Template Parameters

It can be useful to allow a template parameter itself to be a class
template. Again, our stack class template can be used as an example. To
use a different internal container for stacks, the application programmer
has to specify the element type twice. Thus, to specify the type of the
internal container, you have to pass the type of the container and the
type of its elements again:

Stack<int,std::vector<int vStack; // integer stack that uses a vector

Using template template parameters allows you to declare the Stack class
template by specifying the type of the container without respecifying the
type of its elements:

stack<int,std::vectorvStack; // integer stack that uses a vector

To do this you must specify the second template parameter as a template
template parameter...
Aug 12 '08 #2
On Aug 12, 5:07*pm, * Tong * <sun_tong_...@users.sourceforge.net>
wrote:
Hi,

I'm following the example in "C++ Templates: The Complete Guide",
section 5.4 Template Template Parameters.

It's basics/stack8.hpp example has a statement of "#include <allocator>",
but I got an error for it.
[snip]
allocator.cc:1:23: error: allocator: No such file or directory
[...]

How to fix the above allocator.cc so that it compiles fine?
Use <memoryinstead.

Cheers! --M
Aug 12 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ralf Schneeweiß | last post by:
Hi, there is a book from Andre Wilms describing how to write allocators for STL containers. Unfortunately the MS VC++ Compiler is not supporting the full ANSI standard in the template part of the...
3
by: Bernhard Kick | last post by:
Hi all, I saw this code in the book "Accelerated C++" (chapt 11, iirc): template <class T> class Vec { ... std::allocator<T> alloc; // object to handle memory allocation // ??would static...
3
by: Orjan Westin | last post by:
Hi, I have an interesting (read frustrating) problem. I'm writing a generic container class, which holds data as well as links to other instances of itself, like this: template<class T>...
15
by: Alex Vinokur | last post by:
I am looking for any custom allocator sample code for std::vector. Thanks. -- Alex Vinokur http://mathforum.org/library/view/10978.html http://sourceforge.net/users/alexvn
7
by: Grahamo | last post by:
Hi, can anybody tell me where I can get the boiler plate code for std::allocator. I need to have my version of new and delete called and want to get reference code. My compilers headers are all...
1
by: sharmadeep1980 | last post by:
Hi All, I am facing a very unique problem while compling my project in "Release" build. The project is building in DEBUG mode but giving linking error on Release build. Here is the error:...
1
by: xqxu.pzhou | last post by:
I wrote a simple allocator "myAlloc" under the g++ 3.2.3. When it is used by Vector, it works well. But when it is used by List, the codes have errors when compling. the error message is: "no...
6
by: Juha Nieminen | last post by:
I tested the speed of a simple program like this: //------------------------------------------------------------ #include <list> #include <boost/pool/pool_alloc.hpp> int main() { typedef...
16
by: PeterAPIIT | last post by:
Hello all C++ expert programmer, i have wrote partial general allocator for my container. After reading standard C++ library and code guru article, i have several questions. 1. Why...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.