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

How to now the type of a boost::list_of object??

I remember there was a trick to get the type of a anonymous variable
(like a boost::lambda functor or a boost::list_of object) so you can
store it in a variable.
You had to generate a specific compilation error and then look for the
type definition in the error text that the compiler outputs (or
somethig like that).

Does anyone know exactly how to do it??
Oct 10 '08 #1
4 2879
On Oct 11, 7:41*am, Hermann <Hermann.Rich...@gmail.comwrote:
I remember there was a trick to get the type of a anonymous variable
(like a boost::lambda functor or a boost::list_of object) so you can
store it in a variable.
You had to generate a specific compilation error and then look for the
type definition in the error text that the compiler outputs (or
somethig like that).

Does anyone know exactly how to do it??
Wild guess: "How to now" is "How to name"

boost::list_of returns something that is implementation-defined.
all we have to know is that what types it it convertible to.
this idiom is like boost::bind, which returns something convertible
to boost::function. when we need to store what boost::bind returns,
use boost::function.

the types that supports boost::list_of
http://www.boost.org/doc/libs/1_36_0...x.html#list_of
para.3
Oct 11 '08 #2
On Oct 10, 9:17*pm, Barry <dhb2...@gmail.comwrote:
>
Wild guess: "How to now" is "How to name"
No, I just missed a kay (How to Know...).

boost::list_of returns something that is implementation-defined.
I didn't know boost::list_of were part of a standard. I mean, Boost
library is just that, right? a library. Or is it an implementation of
a standard??
Oct 11 '08 #3
On Oct 11, 10:06*am, Hermann <Hermann.Rich...@gmail.comwrote:
On Oct 10, 9:17*pm, Barry <dhb2...@gmail.comwrote:
Wild guess: "How to now" is "How to name"

No, I just missed a kay (How to Know...).
boost::list_of returns something that is implementation-defined.

I didn't know boost::list_of were part of a standard. I mean, Boost
library is just that, right? a library. Or is it an implementation of
a standard??
Yes, you were right.

I change "implementation details" into "implementation-defined",
just as the document writes.
What I wanted to say is that the library implementer does NOT
expect the user to "know" the exact type of what boost::list_of
returns.

In this issue, it's really painful when debugging this kind of
compile-time error, as typeid(...).name() prints not helpful
information if not useless. Other ways? I'm also expecting to "know".

--
Best Regards
Barry
Oct 11 '08 #4
Hermann wrote:
I remember there was a trick to get the type of a anonymous variable
(like a boost::lambda functor or a boost::list_of object) so you can
store it in a variable.
You had to generate a specific compilation error and then look for the
type definition in the error text that the compiler outputs (or
somethig like that).

Does anyone know exactly how to do it??
Do you mean something like this

template< typename T >
i_have_no_idea<T>::some_type f(T);

template< typename T >
void g(T o)
{
what_is_the_type tmp = f(o);
}

where you don't know 'what_is_the_type'?
Doesn't your compiler name the type in its complaints
when you try to make 'tmp' a 'bool', 'int', 'std::string',
or 'foo'? I believe that, with my compiler, passing some
unknown type to something like this

template< typename T >
void dummy(T)
{
typedef typename T::some_thing_that_does_not_exist U;
}

(or an equivalent meta functions, if you're in compile-time
land) usually does the trick to get it to name 'T'.

Schobi
Oct 14 '08 #5

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

Similar topics

3
by: Marco | last post by:
Howdy! Given that: Type type = Type.GetType("System.Windows.Forms.Button"); Question: How do I obtain a Button object by only knowing the type object. In other words, how do I fire the...
4
by: Chris | last post by:
I am calling a COM object that returns a type Object and it contains two strings but I can't get them out. Here is the command: object ParamNameObj= localxPCCOMOBJ.xPCTarget.GetParamName (1); ...
9
by: Andy Sutorius | last post by:
Hi, I am receiving the error when compiling the project, "cannot implicitly convert type object to string". The error points to this line of code and underlines the dtrRecipient:...
4
by: Andres | last post by:
Hi all, I have the problem to assign a variable of type object to a specific class at runtime. I want to use a string variable that specify the class a want to set this object. Is something...
9
by: Ben | last post by:
Hello, I'm not a developper, so sorry if it's a stupid question... I'm trying to develop an application in vb.net and I have the following problem: I have some information in an array:...
13
by: Fredrik Strandberg | last post by:
Hi! I receive an object as a System.Object argument to a method. I need to check if the object is a Type object or not (that is, not a specific type, but if the object is a type object in...
2
by: Piaoger Gong | last post by:
Can Template Container hold different type object at a time as the following style: Node<douledNode; Node<int iNode; Is there anyway to have dNode and iNode in the same container? ...
5
by: JH | last post by:
Hi I found that a type/class are both a subclass and a instance of base type "object". It conflicts to my understanding that: 1.) a type/class object is created from class statement 2.) a...
6
by: Deckarep | last post by:
I want to be able to pass in a function a string say: "TextBox" Then I need a way to convert that string representation into a Type object so i can search through some controls and check their...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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: 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:
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
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
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...

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.