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

boost::is_convertible with private inner class

Hi,

I have an Array<Ttemplate that specializes on T's in my program that
inherit from a base class that I've defined called CtorDtorLess. In
my array template, I check if boost::is_convertible<T*, CtorDtorLess*>
returns true, and then don't use placement new to construct.

I've checked in the debugger and everything works with T's that are
public classes. However, I also have some "inner classes" that are
declared in the private section of another, and then use
Array<MyInnerClasswhere appropriate. For some reason, my debugger
does not allow me to step thru code pertaining to MyInnerClass within
Array<T>. Therefore I cannot verify that boost returns true for
is_convertible<T*, CtorDtorLess*when T is MyInnerClass.

My question is whether the fact that T is an inner class declared in a
private section of another would cause is_convertible<T*,
CtorDtorLess*>::value to return false. My guess is that everything is
fine.

Andy

Jun 2 '07 #1
2 1973
an*********@yahoo.com wrote:
>
My question is whether the fact that T is an inner class declared in a
private section of another would cause is_convertible<T*,
CtorDtorLess*>::value to return false. My guess is that everything is
fine.
A debugger is not a testing tool. Write code whose output depends on the
result of that test.

--

-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
Jun 3 '07 #2
On 2 Jun, 21:35, andrew_n...@yahoo.com wrote:
Hi,

I have an Array<Ttemplate that specializes on T's in my program that
inherit from a base class that I've defined called CtorDtorLess. In
my array template, I check if boost::is_convertible<T*, CtorDtorLess*>
returns true, and then don't use placement new to construct.

I've checked in the debugger and everything works with T's that are
public classes. However, I also have some "inner classes" that are
declared in the private section of another, and then use
Array<MyInnerClasswhere appropriate. For some reason, my debugger
does not allow me to step thru code pertaining to MyInnerClass within
Array<T>. Therefore I cannot verify that boost returns true for
is_convertible<T*, CtorDtorLess*when T is MyInnerClass.
debugger has nothing to do with compilation
My question is whether the fact that T is an inner class declared in a
private section of another would cause is_convertible<T*,
CtorDtorLess*>::value to return false. My guess is that everything is
fine.
only if the inner class is not convertible to CtorDtorLess

try this:

#include <iostream>
#include <boost/type_traits/is_convertible.hpp>

struct CtorDtorLess {};

struct T1 : CtorDtorLess {};
struct T2 {};
struct T3
{
struct T1 : CtorDtorLess {};
struct T2 {};
};

template<class T, bool b>
struct Array;

template<class T>
struct Array<T, true>
{
Array()
{
std::cout << "convertible\n";
}
};

template<class T>
struct Array<T, false>
{
Array()
{
std::cout << "non convertible\n";
}
};

int main()
{
Array<T1, boost::is_convertible<T1*, CtorDtorLess*>::value a1;
Array<T2, boost::is_convertible<T2*, CtorDtorLess*>::valuea2;
Array<T3::T1, boost::is_convertible<T3::T1*, CtorDtorLess*>::value>
a31;
Array<T3::T2, boost::is_convertible<T3::T2*, CtorDtorLess*>::value>
a32;

return 0;
}
DS

Jun 4 '07 #3

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

Similar topics

2
by: krema2ren | last post by:
Hi I've the following header problem that I need two classes to know each other through a boost::shared_ptr. Does any of you smart guys have a solution? A.h ---------------------- #include...
1
by: =?UTF-8?B?SmVucyBNw7xsbGVy?= | last post by:
(I also posted this to boost-user) The BGL implementation of breadth-first search uses a dedicated color map. I had the following idea: Some algorithms don't need to distinguish black/gray,...
0
by: Abhishek Padmanabh | last post by:
I have been trying out boost's serialization library for the past few days. And I have come across a problem serializing a class that has a reference member. The code is posted as below: ...
5
by: GaryE | last post by:
Hello: I am having trouble linking a couple of files using the boost::filesystem. I am using MSVC 6.0. Here is an abbreviated version of my problem: foo.h: #ifndef __FOO_ #define...
2
by: mkvenkit.vc | last post by:
Hello, I hope this is the right place to post a question on Boost. If not, please let me know where I can post this message and I will do so. I am having a strange problem with std::string as...
2
by: Man4ish | last post by:
I have created Graph object without vertex and edge property.It is working fine. #include <boost/config.hpp> #include <iostream> #include <vector> #include <string> #include...
1
by: Rune Allnor | last post by:
Hi all. I am sure this is an oldie, but I can't find a useful suggestion on how to solve it. I have a class hierarchy of classes derived from a base class. I would like to set up a vector of...
19
by: =?ISO-8859-1?Q?Nordl=F6w?= | last post by:
I am currently designing a synchronized queue used to communicate between threads. Is the code given below a good solution? Am I using mutex lock/unlock more than needed? Are there any resources...
4
by: Bit Byter | last post by:
I want to write a (singleton) container for instances of my class templates, however, I am not too sure on how to: 1). Store the instances 2). How to write the acccesor method (instance()) to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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...
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,...

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.