[cfe-dev] New C++0x feature support in Clang

Larry Evans cppljevans at suddenlink.net
Sat Jan 29 03:16:39 PST 2011


On 01/26/11 15:45, Douglas Gregor wrote:
> Clang has recently gotten much-improved support for the upcoming
> C++0x standard. In particular, top-of-tree Clang now supports a
> number of C++0x features:
>
> 	- Rvalue references (including rvalue references for *this)
> 	- Variadic templates
> 	- Inline namespaces
> 	- Late-specified return types
> 	- Decltype
>
> You can turn on C++0x support with the -std=gnu++0x (or, if you want
> to be more pedantic, -std=c++0x).
>
> Give it a spin, write some tests, try it out with libc++, and tell
> us how it went!

Thanks Doug.

It worked fine with:

template<typename... T>
struct A
{
    static unsigned const size=sizeof...(T);
};

int main(void)
{
    return A<int,int,int>::size;
}

So I tried the TestVariantBinary.cpp code found in:

  variant_compare.zip

found here:


http://www.boostpro.com/vault/index.php?&direction=0&order=&directory=Data%20Structures

however, that produced compile-time errors as shown below.
What should I do to workaround those errors?

TIA.

-regards,
Larry

/home/evansl/download/llvm/svn/build/Debug+Asserts/bin/clang -c
-std=c++0x
-I/home/evansl/prog_dev/boost-svn/ro/sandbox/rw/variadic_templates/libs/composite_storage/sandbox/pack/variant_compare/ppboost
-I/home/evansl/prog_dev/boost-svn/ro/sandbox/ro/switch
-I/home/evansl/prog_dev/boost-svn/ro/trunk  -DTEMPLATE_DEPTH=300
TestVariantBinary.cpp -MMD -o
/home/evansl/prog_dev/boost-svn/ro/trunk/sandbox-local/build/clang/boost-svn/ro/sandbox/rw/variadic_templates/libs/composite_storage/sandbox/pack/variant_compare/TestVariantBinary.o

In file included from TestVariantBinary.cpp:33:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/vector.hpp:19:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/aux_/na.hpp:17:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/bool.hpp:17:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/bool_fwd.hpp:17:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/aux_/adl_barrier.hpp:17:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/aux_/config/adl.hpp:17:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/aux_/config/msvc.hpp:19:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/config.hpp:40:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/config/select_stdlib_config.hpp:33:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/config/no_tr1/utility.hpp:21:
In file included from /usr/include/c++/4.4/utility:62:
In file included from /usr/include/c++/4.4/bits/stl_pair.h:60:
In file included from /usr/include/c++/4.4/bits/move.h:38:
In file included from /usr/include/c++/4.4/type_traits:50:
/usr/include/c++/4.4/tr1_impl/type_traits:233:29: error: type qualifier
is not allowed on this function
    struct is_function<_Res(_ArgTypes...) const>
                            ^
/usr/include/c++/4.4/tr1_impl/type_traits:233:12: error: redefinition of
'is_function<type-parameter-0-0
      (type-parameter-0-1...)>'
    struct is_function<_Res(_ArgTypes...) const>
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.4/tr1_impl/type_traits:227:12: note: previous
definition is here
    struct is_function<_Res(_ArgTypes...)>
           ^
/usr/include/c++/4.4/tr1_impl/type_traits:236:29: error: type qualifier
is not allowed on this function
    struct is_function<_Res(_ArgTypes......) const>
                            ^
/usr/include/c++/4.4/tr1_impl/type_traits:236:12: error: redefinition of
'is_function<type-parameter-0-0
      (type-parameter-0-1..., ...)>'
    struct is_function<_Res(_ArgTypes......) const>
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.4/tr1_impl/type_traits:230:12: note: previous
definition is here
    struct is_function<_Res(_ArgTypes......)>
           ^
/usr/include/c++/4.4/tr1_impl/type_traits:239:29: error: type qualifier
is not allowed on this function
    struct is_function<_Res(_ArgTypes...) volatile>
On 01/26/11 15:45, Douglas Gregor wrote:
> Clang has recently gotten much-improved support for the upcoming
> C++0x standard. In particular, top-of-tree Clang now supports a
> number of C++0x features:
>
> 	- Rvalue references (including rvalue references for *this)
> 	- Variadic templates
> 	- Inline namespaces
> 	- Late-specified return types
> 	- Decltype
>
> You can turn on C++0x support with the -std=gnu++0x (or, if you want
> to be more pedantic, -std=c++0x).
>
> Give it a spin, write some tests, try it out with libc++, and tell
> us how it went!

Thanks Doug.

It worked fine with:

template<typename... T>
struct A
{
    static unsigned const size=sizeof...(T);
};

int main(void)
{
    return A<int,int,int>::size;
}

So I tried the TestVariantBinary.cpp code found in:

  variant_compare.zip

found here:


http://www.boostpro.com/vault/index.php?&direction=0&order=&directory=Data%20Structures

however, that produced compile-time errors as shown below.
What should I do to workaround those errors?

TIA.

-regards,
Larry

/home/evansl/download/llvm/svn/build/Debug+Asserts/bin/clang -c
-std=c++0x
-I/home/evansl/prog_dev/boost-svn/ro/sandbox/rw/variadic_templates/libs/composite_storage/sandbox/pack/variant_compare/ppboost
-I/home/evansl/prog_dev/boost-svn/ro/sandbox/ro/switch
-I/home/evansl/prog_dev/boost-svn/ro/trunk  -DTEMPLATE_DEPTH=300
TestVariantBinary.cpp -MMD -o
/home/evansl/prog_dev/boost-svn/ro/trunk/sandbox-local/build/clang/boost-svn/ro/sandbox/rw/variadic_templates/libs/composite_storage/sandbox/pack/variant_compare/TestVariantBinary.o

In file included from TestVariantBinary.cpp:33:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/vector.hpp:19:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/aux_/na.hpp:17:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/bool.hpp:17:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/bool_fwd.hpp:17:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/aux_/adl_barrier.hpp:17:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/aux_/config/adl.hpp:17:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/mpl/aux_/config/msvc.hpp:19:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/config.hpp:40:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/config/select_stdlib_config.hpp:33:
In file included from
/home/evansl/prog_dev/boost-svn/ro/trunk/boost/config/no_tr1/utility.hpp:21:
In file included from /usr/include/c++/4.4/utility:62:
In file included from /usr/include/c++/4.4/bits/stl_pair.h:60:
In file included from /usr/include/c++/4.4/bits/move.h:38:
In file included from /usr/include/c++/4.4/type_traits:50:
/usr/include/c++/4.4/tr1_impl/type_traits:233:29: error: type qualifier
is not allowed on this function
    struct is_function<_Res(_ArgTypes...) const>
                            ^
/usr/include/c++/4.4/tr1_impl/type_traits:233:12: error: redefinition of
'is_function<type-parameter-0-0
      (type-parameter-0-1...)>'
    struct is_function<_Res(_ArgTypes...) const>
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.4/tr1_impl/type_traits:227:12: note: previous
definition is here
    struct is_function<_Res(_ArgTypes...)>
           ^
/usr/include/c++/4.4/tr1_impl/type_traits:236:29: error: type qualifier
is not allowed on this function
    struct is_function<_Res(_ArgTypes......) const>
                            ^
/usr/include/c++/4.4/tr1_impl/type_traits:236:12: error: redefinition of
'is_function<type-parameter-0-0
      (type-parameter-0-1..., ...)>'
    struct is_function<_Res(_ArgTypes......) const>
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.4/tr1_impl/type_traits:230:12: note: previous
definition is here
    struct is_function<_Res(_ArgTypes......)>
           ^
/usr/include/c++/4.4/tr1_impl/type_traits:239:29: error: type qualifier
is not allowed on this function
    struct is_function<_Res(_ArgTypes...) volatile>

...




More information about the cfe-dev mailing list