This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Intrinsics for N2965: Type traits and base classes
- From: Benjamin Kosnik <bkoz at redhat dot com>
- To: Mike Spertus <mike_spertus at symantec dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>, libstdc++ at gcc dot gnu dot org
- Date: Tue, 27 Sep 2011 19:59:30 -0700
- Subject: Re: Intrinsics for N2965: Type traits and base classes
- References: <20110913154324.4be22faf@shotwell> <4E809F45.2010908@symantec.com>
> This patch consists intrinsics to properly create the bases and
> direct_bases of a class in the correct order (including multiple
> nested ambiguous virtual and non-virtual classes) for N2965
> (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2965.html).
> This allows you to create type traits for giving the base classes of
> the class:
>
> template<typename _Tp>
> struct bases
> {
> typedef tuple<__bases(_Tp)...> type;
> };
Cool! So glad to see this.
> I didn't modify the standard library to include the above type trait
> in the patch because it is not yet clear what type it should return
> (e.g., a tuple, a "typelist," something satisfying the requirements
> of a boost::mpl sequence, or a generalization of parameter packs). I
> have (cursorily) tested it with the above type trait and the
> corresponding direct_bases trait.
OK.
Here's a patch for the above. What's wrong with tuple? I kind of like
it.... seems simple. It's what's in N2965, so let's start there.
Since it's the first TR2 header, I did the build bits for you.
Also, I cc'd the library list.
best,
benjamin
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index a59a0b6..e1176ee 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,14 @@
2011-09-27 Benjamin Kosnik <bkoz@redhat.com>
+ * doc/Makefile.am: Add tr2 support.
+ * doc/Makefile.in: Regenerate.
+
+2011-09-27 Mike Spertus <mike_spertus@symantec.com>
+
+ * include/tr2/type_traits (bases, direct_bases): New.
+
+2011-09-27 Benjamin Kosnik <bkoz@redhat.com>
+
* doc/html/*: Regenerate.
* doc/Makefile.am: Un-nest the ext output directory.
diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index 4016882..9fdaa8d 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -604,6 +604,11 @@ tr1_headers = \
${tr1_srcdir}/wchar.h \
${tr1_srcdir}/wctype.h
+tr2_srcdir = ${glibcxx_srcdir}/include/tr2
+tr2_builddir = ./tr2
+tr2_headers = \
+ ${tr2_srcdir}/type_traits
+
decimal_srcdir = ${glibcxx_srcdir}/include/decimal
decimal_builddir = ./decimal
decimal_headers = \
@@ -887,7 +892,7 @@ endif
# CLEANFILES and all-local are kept up-to-date.
allstamped = \
stamp-std stamp-bits stamp-bits-sup stamp-c_base stamp-c_compatibility \
- stamp-backward stamp-ext stamp-pb stamp-tr1 stamp-decimal \
+ stamp-backward stamp-ext stamp-pb stamp-tr1 stamp-tr2 stamp-decimal \
stamp-debug stamp-parallel stamp-profile stamp-profile-impl \
stamp-host
@@ -1002,6 +1007,11 @@ stamp-tr1: ${tr1_headers}
@-cd ${tr1_builddir} && $(LN_S) $? . 2>/dev/null
@$(STAMP) stamp-tr1
+stamp-tr2: ${tr2_headers}
+ @-mkdir -p ${tr2_builddir}
+ @-cd ${tr2_builddir} && $(LN_S) $? . 2>/dev/null
+ @$(STAMP) stamp-tr2
+
stamp-decimal: ${decimal_headers}
@-mkdir -p ${decimal_builddir}
@-cd ${decimal_builddir} && $(LN_S) $? . 2>/dev/null
@@ -1245,6 +1255,9 @@ install-headers:
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${tr1_builddir}
for file in ${tr1_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${tr1_builddir}; done
+ $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${tr2_builddir}
+ for file in ${tr2_headers}; do \
+ $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${tr2_builddir}; done
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${decimal_builddir}
for file in ${decimal_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${decimal_builddir}; done
@@ -1291,7 +1304,7 @@ clean-local:
# developer tries to create them via make in the include build
# directory. (This is more of an example of how this kind of rule can
# be made.)
-.PRECIOUS: $(std_headers) $(c_base_headers) $(tr1_headers)
+.PRECIOUS: $(std_headers) $(c_base_headers) $(tr1_headers) $(tr2_headers)
$(decimal_headers) $(ext_headers)
$(std_headers): ; @:
$(c_base_headers): ; @:
diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in
index 58dbfc4..5ad5932 100644
--- a/libstdc++-v3/include/Makefile.in
+++ b/libstdc++-v3/include/Makefile.in
@@ -854,6 +854,11 @@ tr1_headers = \
${tr1_srcdir}/wchar.h \
${tr1_srcdir}/wctype.h
+tr2_srcdir = ${glibcxx_srcdir}/include/tr2
+tr2_builddir = ./tr2
+tr2_headers = \
+ ${tr2_srcdir}/type_traits
+
decimal_srcdir = ${glibcxx_srcdir}/include/decimal
decimal_builddir = ./decimal
decimal_headers = \
@@ -1125,7 +1130,7 @@ PCHFLAGS = -x c++-header -nostdinc++ $(CXXFLAGS)
# CLEANFILES and all-local are kept up-to-date.
allstamped = \
stamp-std stamp-bits stamp-bits-sup stamp-c_base stamp-c_compatibility \
- stamp-backward stamp-ext stamp-pb stamp-tr1 stamp-decimal \
+ stamp-backward stamp-ext stamp-pb stamp-tr1 stamp-tr2 stamp-decimal \
stamp-debug stamp-parallel stamp-profile stamp-profile-impl \
stamp-host
@@ -1402,6 +1407,11 @@ stamp-tr1: ${tr1_headers}
@-cd ${tr1_builddir} && $(LN_S) $? . 2>/dev/null
@$(STAMP) stamp-tr1
+stamp-tr2: ${tr2_headers}
+ @-mkdir -p ${tr2_builddir}
+ @-cd ${tr2_builddir} && $(LN_S) $? . 2>/dev/null
+ @$(STAMP) stamp-tr2
+
stamp-decimal: ${decimal_headers}
@-mkdir -p ${decimal_builddir}
@-cd ${decimal_builddir} && $(LN_S) $? . 2>/dev/null
@@ -1630,6 +1640,9 @@ install-headers:
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${tr1_builddir}
for file in ${tr1_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${tr1_builddir}; done
+ $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${tr2_builddir}
+ for file in ${tr2_headers}; do \
+ $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${tr2_builddir}; done
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${decimal_builddir}
for file in ${decimal_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${decimal_builddir}; done
@@ -1673,7 +1686,7 @@ clean-local:
# developer tries to create them via make in the include build
# directory. (This is more of an example of how this kind of rule can
# be made.)
-.PRECIOUS: $(std_headers) $(c_base_headers) $(tr1_headers)
+.PRECIOUS: $(std_headers) $(c_base_headers) $(tr1_headers) $(tr2_headers)
$(decimal_headers) $(ext_headers)
$(std_headers): ; @:
$(c_base_headers): ; @: