473,396 Members | 1,967 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,396 software developers and data experts.

boost::has_trivial_constructor doesn't work

Hi,

I'm using the latest version of Intel Linux Compiler, offers boost
built-in. I include <boost/type_traits/has_trivial_constructor.hpp>,
create a simple struct as follows:

struct MyStruct {
// no constructor!
};

and find that expression
boost::has_trivial_constructor<MyStruct>::value is false.

This is too wierd. Isn't that a bug in my boost package?

Thanks,
Andy

Jun 2 '07 #1
5 2289
On Sat, 02 Jun 2007 10:46:55 -0700, an*********@yahoo.com wrote:
>Hi,

I'm using the latest version of Intel Linux Compiler, offers boost
built-in. I include <boost/type_traits/has_trivial_constructor.hpp>,
create a simple struct as follows:

struct MyStruct {
// no constructor!
};

and find that expression
boost::has_trivial_constructor<MyStruct>::value is false.

This is too wierd. Isn't that a bug in my boost package?
Please read the documentation which comes with your boost package
(has_trivial_constructor<requires help from the compiler).

--
Gennaro Prota -- C++ Developer, For Hire
https://sourceforge.net/projects/breeze/
(replace 'address' with 'name.surname' to mail)
Jun 2 '07 #2
an*********@yahoo.com wrote:
Hi,

I'm using the latest version of Intel Linux Compiler, offers boost
built-in. I include <boost/type_traits/has_trivial_constructor.hpp>,
create a simple struct as follows:

struct MyStruct {
// no constructor!
};

and find that expression
boost::has_trivial_constructor<MyStruct>::value is false.

This is too wierd. Isn't that a bug in my boost package?
Nobody has figured out how to implement has_trivial_constructor without
compiler help. In TR1, it's allowed to always return false. That's
usually a safe fallback -- if you're using it to determine whether you
can use memcpy to initialize an array of that type, answering no means
you won't do any damage. (For more details, see chapter 11 of my book,
"The Standard C++ Library Extensions".)

--

-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
Jun 2 '07 #3
On Jun 2, 2:42 pm, Pete Becker <p...@versatilecoding.comwrote:
andrew_n...@yahoo.com wrote:
Hi,
I'm using the latest version of Intel Linux Compiler, offers boost
built-in. I include <boost/type_traits/has_trivial_constructor.hpp>,
create a simple struct as follows:
struct MyStruct {
// no constructor!
};
and find that expression
boost::has_trivial_constructor<MyStruct>::value is false.
This is too wierd. Isn't that a bug in my boost package?

Nobody has figured out how to implement has_trivial_constructor without
compiler help. In TR1, it's allowed to always return false. That's
usually a safe fallback -- if you're using it to determine whether you
can use memcpy to initialize an array of that type, answering no means
you won't do any damage. (For more details, see chapter 11 of my book,
"The Standard C++ Library Extensions".)

Well that's good info! I know which classes of mine have trivial
constructors. For those, I inherit from an empty struct called
CtorDtorLess. I have gotten a meta-programming fragment from
Alexandrescu that uses a function with ... argument to distinguish
between structs that inherit from another struct versus not.

Unfortunately, on my compiler, I am getting a warning 1595 cannot pass
POD to elipses. Disabling that warning allows it to work.

Can you tell me what boost replacement there is for determining if a
struct inherits from another? I'm hoping I can use that instead and
avoid the warning.

Andy

Jun 2 '07 #4
I partially answered my own question, use boost::is_base_of<B,
D>::value, but it seems like this is unavailable in the latest Linux
Compiler from Intel.

I #include <boost/type_traits.hpp>, for which there is no complaint,
and then use boost::is_base_of<B, D>::value but the compiler complains
that it can't find is_base_of.

Also, when I #include <boost/type_traits/is_base_of.hppI get a
catastrophic error, saying that this include does not exist.

Is this such a recent addition to boost, that it didn't make its way
into the Linux version 9.1.49 that I just downloaded?

Andy

Jun 2 '07 #5
an*********@yahoo.com wrote:
I partially answered my own question, use boost::is_base_of<B,
D>::value, but it seems like this is unavailable in the latest Linux
Compiler from Intel.
I think the name in Boost is is_base_and_derived. But you should be
asking about Boost at www.boost.org.

In TR1 it's is_base_of

--

-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
Jun 2 '07 #6

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

Similar topics

5
by: SnaiL | last post by:
I've try to compile simple program which uses boost::program_options and got error like this: LINK : fatal error LNK1104: cannot open file 'libboost_program_options-vc7-mt-s-1_32.lib' I was...
16
by: Jeff Flinn | last post by:
At the risk of raising the OT ire of some here, I'd like to know what might be done to raise the awareness of the boost libraries. I've found boost and it's libraries invaluable in my work for ~5...
3
by: Rafal Dabrowa | last post by:
Suppose I have the following structure: struct xy { int x, y; }; and the following vector: vector<xy> v(10); I want to use boost/lambda for find an item in the table. Let's say, with x...
7
by: derek.google | last post by:
I hope a Boost question is not too off-topic here. It seems that upgrading to Boost 1.33 broke some old regex code that used to work. I have reduced the problem to this simple example: cout <<...
34
by: Guch Wu | last post by:
Boost has many terrific libraries. But I want to know whether they are ready for using in real projects. Which of them are mature enough, or just only in progress?
6
by: Toby Bradshaw | last post by:
Hi, Consider the following: class A { public: virtual bool foo() = 0; };
7
by: myfavdepo | last post by:
Hi all, I have a query regarding the exchanging of a boost::shared_ptr beween different threads. In my program i've two threads both of which having their own internal queues for storing the...
9
by: Chelong | last post by:
Hi All I am using the srand function generate random numbers.Here is the problem. for example: #include<iostream> #include <time.h> int main() {
9
by: Christopher | last post by:
If a method is declared to return a type boost::shared_ptr<sometype>, how can the method be changed to do the equivalent of returning NULL when it was declared to return a raw pointer?
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
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...
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.