Hello,
I am looking for a little bit of help. I am trying to create a
dynamically allocated object which contains one or more objects of
type boost::pool<>. I get a compiler error when an object of this type
is contained in my class and am not sure why. To be honest I have a
little but not a lot of experience with templates and it could simply
be obvious to a more experienced template user; however, the answer
escapes me.
Here is a sample code snippet:
#include <boost/pool/pool.hpp>
#include <boost/pool/singleton_pool. hpp>
struct Foobar
{
boost::pool<p(s izeof(int)); // this is line 182
};
boost::pool<yp( 512);
int main()
{
Foobar foobar;
printf( "%u\n", sizeof( boost::pool<>(5 12) ) );
return( 0 );
}
----------------------
Here is the error message:
ramMgr.cxx:182: error: expected identifier before #sizeof#
ramMgr.cxx:182: error: expected #,# or #...# before #sizeof#
---------------------------
compiler & version
g++ -v
gcc version 4.1.1 20060724 (4.1.1-3mdk)
Thanks,
Parker 5 2849
mackenzie wrote:
Hello,
I am looking for a little bit of help. I am trying to create a
dynamically allocated object which contains one or more objects of
type boost::pool<>. I get a compiler error when an object of this type
is contained in my class and am not sure why. To be honest I have a
little but not a lot of experience with templates and it could simply
be obvious to a more experienced template user; however, the answer
escapes me.
Here is a sample code snippet:
#include <boost/pool/pool.hpp>
#include <boost/pool/singleton_pool. hpp>
struct Foobar
{
boost::pool<p(s izeof(int)); // this is line 182
What's the 'sizeof' for? Are you trying to initialise it? If so,
initialisation of members belongs to constructor initialiser list.
If you were trying to declare an array, then replace parentheses
with brackets. Most likely you just need to lose the parentheses
and the expression inside them.
>
};
boost::pool<yp( 512);
int main()
{
Foobar foobar;
printf( "%u\n", sizeof( boost::pool<>(5 12) ) );
return( 0 );
}
----------------------
Here is the error message:
ramMgr.cxx:182: error: expected identifier before #sizeof#
ramMgr.cxx:182: error: expected #,# or #...# before #sizeof#
---------------------------
compiler & version
g++ -v
gcc version 4.1.1 20060724 (4.1.1-3mdk)
Thanks,
Parker
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
On Jun 13, 4:54 pm, "Victor Bazarov" <v.Abaza...@com Acast.netwrote:
mackenzie wrote:
Hello,
I am looking for a little bit of help. I am trying to create a
dynamically allocated object which contains one or more objects of
type boost::pool<>. I get a compiler error when an object of this type
is contained in my class and am not sure why. To be honest I have a
little but not a lot of experience with templates and it could simply
be obvious to a more experienced template user; however, the answer
escapes me.
Here is a sample code snippet:
#include <boost/pool/pool.hpp>
#include <boost/pool/singleton_pool. hpp>
struct Foobar
{
boost::pool<p(s izeof(int)); // this is line 182
What's the 'sizeof' for? Are you trying to initialise it? If so,
initialisation of members belongs to constructor initialiser list.
If you were trying to declare an array, then replace parentheses
with brackets. Most likely you just need to lose the parentheses
and the expression inside them.
};
boost::pool<yp( 512);
int main()
{
Foobar foobar;
printf( "%u\n", sizeof( boost::pool<>(5 12) ) );
return( 0 );
}
----------------------
Here is the error message:
ramMgr.cxx:182: error: expected identifier before #sizeof#
ramMgr.cxx:182: error: expected #,# or #...# before #sizeof#
---------------------------
compiler & version
g++ -v
gcc version 4.1.1 20060724 (4.1.1-3mdk)
Thanks,
Parker
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Thanks for responding.
What I thought I was doing was creating a member of Foobar named p of
type boost::pool<whi ch takes a size_type as an argument to the
constructor. It seems to work in the global name space; however, when
I put it into a structure or class I get the error.
>From : http://www.boost.org/libs/pool/doc/interfaces/pool.html
template <typename UserAllocator = default_user_al locator_new_del ete>
class pool
{...
explicit pool(size_type requested_size) ;
};
Perhaps after the drive home and a clearer head I will stare at it
some more with your suggestion in mind and the answer will be a little
more obvious.
Thanks,
Parker
mackenzie wrote:
On Jun 13, 4:54 pm, "Victor Bazarov" <v.Abaza...@com Acast.netwrote:
>mackenzie wrote:
>>Hello, I am looking for a little bit of help. I am trying to create a dynamically allocated object which contains one or more objects of type boost::pool<>. I get a compiler error when an object of this type is contained in my class and am not sure why. To be honest I have a little but not a lot of experience with templates and it could simply be obvious to a more experienced template user; however, the answer escapes me.
>>Here is a sample code snippet:
>>#include <boost/pool/pool.hpp> #include <boost/pool/singleton_pool. hpp>
>>struct Foobar { boost::pool<p(s izeof(int)); // this is line 182
What's the 'sizeof' for? Are you trying to initialise it? If so, initialisati on of members belongs to constructor initialiser list. If you were trying to declare an array, then replace parentheses with brackets. Most likely you just need to lose the parentheses and the expression inside them. [..]
What I thought I was doing was creating a member of Foobar named p of
type boost::pool<whi ch takes a size_type as an argument to the
constructor.
You're trying to provide a particular argument in a declaration.
That's not how you initialise the member. Please read about
constructors (of classes) and the _member_initial iser_lists_.
It seems to work in the global name space; however, when
I put it into a structure or class I get the error.
>From : http://www.boost.org/libs/pool/doc/interfaces/pool.html
template <typename UserAllocator = default_user_al locator_new_del ete>
class pool
{...
explicit pool(size_type requested_size) ;
};
Perhaps after the drive home and a clearer head I will stare at it
some more with your suggestion in mind and the answer will be a little
more obvious.
Thanks,
Parker
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Thank you Victor.
That makes perfect sense. I was looking at it as if it was being
passed in as a template argument. When in fact it is similar to any
other class.
Thanks again,
Parker
On Jun 14, 7:34 am, mackenzie <themackenziefa m...@gmail.comw rote:
Thank you Victor.
That makes perfect sense. I was looking at it as if it was being
passed in as a template argument. When in fact it is similar to any
other class.
Thanks again,
Parker
For completeness, in case someone else has a similar question in the
future, the following is the corrected code:
struct Foobar
{
boost::pool<p; // this was line 182
Foobar() : p( 5 ) {}
};
Reference: 10.4.6.1 Necessary Member Initialization; The C++
Programming Language; Bjarne Stroustrup; May 2004
Thanks again Victor. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jeremy Siek |
last post by:
CALL FOR PAPERS/PARTICIPATION
C++, Boost, and the Future of C++ Libraries
Workshop at OOPSLA
October 24-28, 2004
Vancouver, British Columbia, Canada
http://tinyurl.com/4n5pf
Submissions
|
by: newbiecpp |
last post by:
I have hard time to understand run-time environment. Let assume that I have
a program that has a simple variable alpha. When this variable is
statically allocated, the compiler can use the absolute address of alpha to
access to it. What confuses me is that when the variable is dynamically
allocated, how does the compiler implement it? We know the address of the
variable until run-time. During the compilation, how can we access to the...
|
by: Peter Frost |
last post by:
Please help
I don't know if this is possible but what I would really like to do is
to use On Error Goto to capture the code that is being executed when
an error occurs.
Any help would be much appreciated.
Thanks in advance
|
by: ufnuceda |
last post by:
Hello everyone,
I was wondering if any of you have some experience with the boost
library. I am having trouble compiling code with it. Since boost is
being used a lot these days I thought some of you might have an answer.
I would greatly appreciate help with this, as I tried to search for an
answer for quite some time in vain.
I am getting error messages when I try to compile as soon as I put an
include to the boost library in the...
|
by: tony |
last post by:
Hello!
My question is about calling this method CollectData below but I get a
compile error that I shouldn't have because the type parameter is correct.
The compile error is the following:
C:\PK\Development\Products\UTCAS\4.0\SRC\MeltPracApplication\Dialog\Composit
ionForm.cs(942): Argument '1': cannot convert from 'ref
MeltPracData.MeltPracDataComposition' to 'ref
MeltPracCommon.IDialogPostData'
| |
by: Noah Roberts |
last post by:
Trying to use boost::function in a C++/CLI program. Here is code:
pragma once
#include <boost/function.hpp>
#include <boost/shared_ptr.hpp>
#include <vector>
using namespace System;
|
by: silverburgh.meryl |
last post by:
I have code which uses Boost lambda in a template like this:
using namespace boost::lambda;
template<class T>
bool lessThanXY( T& src, T& dest ) {
return (src.getY() < dest.getY());
}
template<class T1, class T2>
|
by: werasm |
last post by:
Hi,
This is not boost related per sé, therefore I'm posing the question
here.
I need to do many small object allocations, and I'm considering
using boost::pool for this. I've contemplated using Coplien's CRTP
to encapsulate the allocation/de-allocation and the pool per type.
Does anybody see a potential caveat here? One potential caveat
|
by: varnie |
last post by:
hell-o !~
i faced weird problem during usage boost::pool_allocator.
after i've changed:
typedef boost::shared_ptr< param > ParamPtr;
typedef std::vector< ParamPtr > ParamPtrVector;
with:
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |