473,398 Members | 2,212 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,398 software developers and data experts.

SGI/STL __STL_CLASS_REQUIRES(_Tp, _Assignable);

7
Expand|Select|Wrap|Line Numbers
  1. __STL_CLASS_REQUIRES(_Tp, _Assignable);
This sentence appears many times int the SGI/STL source code.
However, this macro seems to do nothing int the cource code.
The Following is the Macro Definition in concept_checks.h:

Expand|Select|Wrap|Line Numbers
  1. #ifndef __STL_USE_CONCEPT_CHECKS
  2.  
  3. // Some compilers lack the features that are necessary for concept checks.
  4. // On those compilers we define the concept check macros to do nothing.
  5. #define __STL_REQUIRES(__type_var, __concept) do {} while(0)
  6. #define __STL_CLASS_REQUIRES(__type_var, __concept) \
  7.   static int  __##__type_var##_##__concept
and

Expand|Select|Wrap|Line Numbers
  1. #ifdef __STL_NO_FUNCTION_PTR_IN_CLASS_TEMPLATE
  2.  
  3. #define __STL_CLASS_REQUIRES(__type_var, __concept)
and

Expand|Select|Wrap|Line Numbers
  1. #else
  2.  
  3. // Use this macro inside of template classes, where you would
  4. // like to place requirements on the template arguments to the class
  5. // Warning: do not pass pointers and such (e.g. T*) in as the __type_var,
  6. // since the type_var is used to construct identifiers. Instead typedef
  7. // the pointer type, then use the typedef name for the __type_var.
  8. #define __STL_CLASS_REQUIRES(__type_var, __concept) \
  9.   typedef void (* __func##__type_var##__concept)( __type_var ); \
  10.   template <__func##__type_var##__concept _Tp1> \
  11.   struct __dummy_struct_##__type_var##__concept { }; \
  12.   static __dummy_struct_##__type_var##__concept< \
  13.     __concept##_concept_specification< \
  14.       __type_var>::__concept##_requirement_violation>  \
  15.   __dummy_ptr_##__type_var##__concept
None of the above definitions seem to be meaningful.
They only declare some variables, but does nothing?
So, Is the COMPLIER that finally defines macros like
__STL_CLASS_REQUIRES?

Thanks!C++ Geeks!
Aug 13 '08 #1
1 1491
RRick
463 Expert 256MB
The compiler does supply some macros (i.e. __LINE__ and __FILE__) but these STL marcros are definitely not of that variety. There is no magic here. What is defined is what you get.

In your example from the top of the post, the macro would create the following code:
Expand|Select|Wrap|Line Numbers
  1.  
  2.   typedef void (* __func_Tp_Assignable)( _Tp ); 
  3.   template <__func_Tp_Assignable _Tp1>  struct __dummy_struct__Tp_Assignable { };
  4.   static __dummy_struct__Tp_Assignable< _Assignable_concept_specification< _Tp>::_Assignable_requirement_violation> __dummy_ptr__Tp_Assignable
  5.  
What's it used for is another question. Try searching in the code for __func and/or __dummy_struct. You might found more interesting bits of info there.

If you still need answers you can try a news group (i.e. c++.stl.sgi or comp.lang.c++). There are some very knowledgable people there.
Aug 14 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: bartek | last post by:
Hello, I've been toying around with expression templates recently while writing a simple static lexical analyser, hence I have some questions which keep bothering me... The expression objects...
17
by: Jacek Dziedzic | last post by:
Hello! I have a templated class that serves as a simple vector of elements. template <typename T> class simple_vector : public math_object { // ... lots of simple_vector operations // the...
46
by: Blue Ocean | last post by:
How do I do it? I'm doing a practice problem which includes me implementing a set of ints as a class. I don't want to use vector because that would be cheating. ;) I don't want to spend...
19
by: Marco Jez | last post by:
Hi everyone! I would like to use the reference returned by typeid as key in a std::map. Is it safe to assume that typeid(T) (where T is a type name) will always return the same reference to the...
1
by: AP | last post by:
Why do I get a conversion error with this line of code? (Type of conditional expression can't be determined because there is no implicit conversion between 'int' and 'System.DBNull') object o =...
2
by: Rodney Maxwell | last post by:
In Python 2.4.1: >>> None = 99 SyntaxError: assignment to None >>> True = 99 >>> False = 99 >>> True == False True ----------------------- So why is 'None' special?
8
by: Luke Meyers | last post by:
I was trying to come up with a neat STL-heavy response to this thread about multimaps: ...
2
by: Rickard | last post by:
I want to dynamically check if I can assign from type A to type B in runtime. Type.IsAssignableFrom does not work for me as, typeof(int).IsAssignableFrom(typeof(short)) returns false, which is...
57
by: buuuuuum | last post by:
why array can't be assigned, like structs?
3
by: massysett | last post by:
I'm puzzled about part of the standard. 23.1 states that items stored in a container must be assignable. Therefore, the items in a map--that is, std::pair<const Key, valuemust be assignable....
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...
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,...
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.