do you suggest we do this to valarray?
cat t.cpp && gcc -v && gcc t.cpp && ./a.out
class _slice
{
public:
_slice () : a(0), b(0), c(0) { }
_slice (int _a, int _b, int _c)
: a (_a)
, b (_b)
, c (_c)
{ }
private:
int a,b,c;
};
template <class T>
class _slice_array
{
public:
_slice_array(_slice & __rightSlice)
: __slice (__rightSlice)
{ }
_slice get_slice() const
{
return __slice;
}
private:
_slice_array();
_slice_array& operator = (const _slice_array&);
_slice __slice;
};
int main()
{
_slice aSlice;
_slice_array<int> mySliceArray(aSlice);
_slice_array<int> my2ndSliceArray = mySliceArray;
_slice bSlice = mySliceArray.get_slice();
_slice cSlice = my2ndSliceArray.get_slice();
return 0;
}
Using built-in specs.
Target: i586-suse-linux
Configured with: ../configure --enable-threads=posix --prefix=/usr
--with-local-prefix=/usr/local --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib --libexecdir=/usr/lib
--enable-languages=c,c++,objc,fortran,obj-c++,java,ada
--enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.1.2
--enable-ssp --disable-libssp --disable-libgcj --with-slibdir=/lib
--with-system-zlib --enable-shared --enable-__cxa_atexit
--enable-libstdcxx-allocator=new --program-suffix=-4.1
--enable-version-specific-runtime-libs --without-system-libunwind
--with-cpu=generic --host=i586-suse-linux
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (SUSE Linux)
Yu (Scott) Zhong
Consulting Engineer
Rogue Wave Software, a Quovadxtm division
[EMAIL PROTECTED]
ph: 303 545 3182
-----Original Message-----
From: Martin Sebor [mailto:[EMAIL PROTECTED]
Sent: Mon 3/12/2007 9:23 AM
To: [email protected]
Subject: Re: openSUSE 10.2 -- gcc 4.1.1/2 -- valarray
Scott Zhong wrote:
> test case appears to work.
Yes. 17.names.cpp tries verifies that the library doesn't use
identifiers that belong to the user namespace. I.e., that user
defined macros (such as T, or get_slice) don't clash with
symbols used by the implementation that aren't reserved by the
C++ standard, such as function argument or template parameter
names, or the names of local variables.
So, for example, this must compile with no error:
#define T !#$%^&
#include <algorithm>
and so does this:
#define get_slice !#$%^&
#include <valarray>
Implementations must use reserved names to get this to work,
which typically means names with two consecutive underscores
(such as __rightSlice), or names that start with an underscore
followed by a capital letter (such as _TypeT).
Martin
>
> cat t.cpp && gcc -v && gcc t.cpp && ./a.out
> class slice
> {
> public:
> slice () : a(0), b(0), c(0) { }
> slice (int _a, int _b, int _c)
> : a (_a)
> , b (_b)
> , c (_c)
> { }
>
> private:
> int a,b,c;
> };
>
> template <class T>
> class slice_array
> {
> public:
> slice_array(slice & __rightSlice)
> : _slice (__rightSlice)
> { }
>
> slice get_slice() const
> {
> return _slice;
> }
>
> private:
> slice_array();
> slice_array& operator = (const slice_array&);
> slice _slice;
> };
>
> int main()
> {
> slice aSlice;
> slice_array<int> mySliceArray(aSlice);
> slice bSlice = mySliceArray.get_slice();
> return 0;
> }
> Using built-in specs.
> Target: i686-pc-linux-gnu
> Configured with: ./configure --prefix=/usr/local/gcc411
> Thread model: posix
> gcc version 4.1.1
>
>
> Yu (Scott) Zhong
>
> -----Original Message-----
> From: Scott Zhong [mailto:[EMAIL PROTECTED]
> Sent: Sun 3/11/2007 11:50 AM
> To: [email protected]
> Subject: openSUSE 10.2 -- gcc 4.1.1/2 -- valarray
>
> on openSUSE 10.2 compiling stdcxx/tests/intro/17.names.cpp with both gcc
> 4.1.1 and gcc 4.1.2 gives this error:
>
> [EMAIL PROTECTED]:~/stdcxx> gcc -c -I/home/scottz/stdcxx/include/ansi
> -D_RWSTDDEBUG -D_RWSTD_USE_CONFIG -I/home/scottz/stdcxx/include
> -I/home/scottz/stdcxx/gcc411/11s/include -I/home/scottz/stdcxx/../rwtest
> -I/home/scottz/stdcxx/../rwtest/include -I/home/scottz/stdcxx/tests/include
> -pedantic -nostdinc++ -g -W -Wall -Wcast-qual -Winline -Wshadow
> -Wwrite-strings -Wno-long-long -v -Wcast-align
> /home/scottz/stdcxx/tests/intro/17.names.cpp
> Using built-in specs.
> Target: i686-pc-linux-gnu
> Configured with: ./configure --prefix=/usr/local/gcc411
> Thread model: posix
> gcc version 4.1.1
> /usr/local/gcc411/libexec/gcc/i686-pc-linux-gnu/4.1.1/cc1plus -quiet
> -nostdinc++ -v -I/home/scottz/stdcxx/include/ansi
> -I/home/scottz/stdcxx/include -I/home/scottz/stdcxx/gcc411/11s/include
> -I/home/scottz/stdcxx/../rwtest -I/home/scottz/stdcxx/../rwtest/include
> -I/home/scottz/stdcxx/tests/include -D_GNU_SOURCE -D_RWSTDDEBUG
> -D_RWSTD_USE_CONFIG /home/scottz/stdcxx/tests/intro/17.names.cpp -quiet
> -dumpbase 17.names.cpp -mtune=pentiumpro -auxbase 17.names -g -pedantic -W
> -Wall -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long
> -Wcast-align -version -o /tmp/ccmQNz95.s
> ignoring nonexistent directory
> "/usr/local/gcc411/lib/gcc/i686-pc-linux-gnu/4.1.1/../../../../i686-pc-linux-gnu/include"
> ignoring nonexistent directory "/home/scottz/stdcxx/../rwtest"
> ignoring nonexistent directory "/home/scottz/stdcxx/../rwtest/include"
> #include "..." search starts here:
> #include <...> search starts here:
> /home/scottz/stdcxx/include/ansi
> /home/scottz/stdcxx/include
> /home/scottz/stdcxx/gcc411/11s/include
> /home/scottz/stdcxx/tests/include
> /usr/local/include
> /usr/local/gcc411/include
> /usr/local/gcc411/lib/gcc/i686-pc-linux-gnu/4.1.1/include
> /usr/include
> End of search list.
> GNU C++ version 4.1.1 (i686-pc-linux-gnu)
> compiled by GNU C version 4.1.2 20061115 (prerelease) (SUSE Linux).
> GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=129366
> Compiler executable checksum: 3bea10c8b1944d495bcb5dfde72a623e
> /home/scottz/stdcxx/include/valarray:1314: error: expected unqualified-id
> before '!' token
> /home/scottz/stdcxx/include/valarray: In copy constructor
> 'std::slice_array<_TypeT>::slice_array(const std::slice_array<_TypeT>&)':
> /home/scottz/stdcxx/include/valarray:1301: error: expected unqualified-id
> before '!' token
> /home/scottz/stdcxx/include/valarray: At global scope:
> /home/scottz/stdcxx/include/valarray:1481: error: expected unqualified-id
> before '!' token
> /home/scottz/stdcxx/include/valarray: In copy constructor
> 'std::gslice_array<_TypeT>::gslice_array(const std::gslice_array<_TypeT>&)':
> /home/scottz/stdcxx/include/valarray:1467: error: expected unqualified-id
> before '!' token
> /home/scottz/stdcxx/include/valarray: At global scope:
> /home/scottz/stdcxx/include/valarray:1532: error: expected unqualified-id
> before '!' token
> /home/scottz/stdcxx/include/valarray: In copy constructor
> 'std::mask_array<_TypeT>::mask_array(const std::mask_array<_TypeT>&)':
> /home/scottz/stdcxx/include/valarray:1520: error: expected unqualified-id
> before '!' token
> /home/scottz/stdcxx/include/valarray: At global scope:
> /home/scottz/stdcxx/include/valarray:1640: error: expected unqualified-id
> before '!' token
> /home/scottz/stdcxx/include/valarray: In copy constructor
> 'std::indirect_array<_TypeT>::indirect_array(const
> std::indirect_array<_TypeT>&)':
> /home/scottz/stdcxx/include/valarray:1627: error: expected unqualified-id
> before '!' token
> /home/scottz/stdcxx/include/valarray: In function 'void
> __rw::__rw_unary_function(const std::slice_array<_TypeT>&, const
> std::valarray<_TypeT>&, _UnaryFunction)':
> /home/scottz/stdcxx/include/valarray:1737: error: expected unqualified-id
> before '!' token
> /home/scottz/stdcxx/include/valarray:1737: error: expected ',' or ';' before
> '!' token
> /home/scottz/stdcxx/include/valarray: In function 'void
> __rw::__rw_binary_function(const std::slice_array<_TypeT>&, const
> std::valarray<_TypeT>&, _BinaryFunction)':
> /home/scottz/stdcxx/include/valarray:1757: error: expected unqualified-id
> before '!' token
> /home/scottz/stdcxx/include/valarray:1757: error: expected ',' or ';' before
> '!' token
> /home/scottz/stdcxx/include/valarray: In constructor
> 'std::valarray<_TypeT>::valarray(const std::slice_array<_TypeT>&)':
> /home/scottz/stdcxx/include/valarray:2077: error: expected primary-expression
> before '(' token
> /home/scottz/stdcxx/include/valarray:2077: error: expected unqualified-id
> before '!' token
> /home/scottz/stdcxx/include/valarray:2079: error: expected unqualified-id
> before '!' token
> /home/scottz/stdcxx/include/valarray:2079: error: expected ',' or ';' before
> '!' token
> /home/scottz/stdcxx/include/valarray:2082: error: expected unqualified-id
> before '!' token
> /home/scottz/stdcxx/include/valarray:2082: error: expected `)' before '!'
> token
> /home/scottz/stdcxx/include/valarray:2082: error: 'ERROR' was not declared in
> this scope
> /home/scottz/stdcxx/include/valarray:2082: error: expected `;' before '!'
> token
> /home/scottz/stdcxx/include/valarray: In member function
> 'std::valarray<_TypeT>& std::valarray<_TypeT>::operator=(const
> std::slice_array<_TypeT>&)':
> /home/scottz/stdcxx/include/valarray:2098: error: expected primary-expression
> before '(' token
> /home/scottz/stdcxx/include/valarray:2098: error: expected unqualified-id
> before '!' token
> /home/scottz/stdcxx/include/valarray:2100: error: expected unqualified-id
> before '!' token
> /home/scottz/stdcxx/include/valarray:2100: error: expected ',' or ';' before
> '!' token
> /home/scottz/stdcxx/include/valarray:2103: error: expected unqualified-id
> before '!' token
> /home/scottz/stdcxx/include/valarray:2103: error: expected `)' before '!'
> token
> /home/scottz/stdcxx/include/valarray:2103: error: 'ERROR' was not declared in
> this scope
> /home/scottz/stdcxx/include/valarray:2103: error: expected `;' before '!'
> token
> /home/scottz/stdcxx/include/valarray: In constructor
> 'std::valarray<_TypeT>::valarray(const std::gslice_array<_TypeT>&)':
> /home/scottz/stdcxx/include/valarray:2144: error: expected unqualified-id
> before '!' token
> /home/scottz/stdcxx/include/valarray:2147: error: 'ERROR' was not declared in
> this scope
> /home/scottz/stdcxx/include/valarray:2149: error: expected ',' or ';' before
> '!' token
> /home/scottz/stdcxx/include/valarray:2152: error: expected `)' before '!'
> token
> /home/scottz/stdcxx/include/valarray:2152: error: expected primary-expression
> before '.' token
> /home/scottz/stdcxx/include/valarray:2152: error: expected `;' before ')'
> token
> /home/scottz/stdcxx/include/valarray: In member function
> 'std::valarray<_TypeT>& std::valarray<_TypeT>::operator=(const
> std::gslice_array<_TypeT>&)':
> /home/scottz/stdcxx/include/valarray:2167: error: expected unqualified-id
> before '!' token
> /home/scottz/stdcxx/include/valarray:2170: error: 'ERROR' was not declared in
> this scope
> /home/scottz/stdcxx/include/valarray:2172: error: expected ',' or ';' before
> '!' token
> /home/scottz/stdcxx/include/valarray:2175: error: expected `)' before '!'
> token
> /home/scottz/stdcxx/include/valarray:2175: error: expected primary-expression
> before '.' token
> /home/scottz/stdcxx/include/valarray:2175: error: expected `;' before ')'
> token
> /home/scottz/stdcxx/include/valarray: In constructor
> 'std::valarray<_TypeT>::valarray(const std::mask_array<_TypeT>&)':
> /home/scottz/stdcxx/include/valarray:2215: error: expected unqualified-id
> before '!' token
> /home/scottz/stdcxx/include/valarray:2215: error: expected initializer before
> '!' token
> /home/scottz/stdcxx/include/valarray:2216: error: expected unqualified-id
> before '!' token
> /home/scottz/stdcxx/include/valarray:2216: error: expected initializer before
> '!' token
> /home/scottz/stdcxx/include/valarray:2220: error: 'ERROR' was not declared in
> this scope
> /home/scottz/stdcxx/include/valarray:2220: error: expected `;' before '!'
> token
> /home/scottz/stdcxx/include/valarray:2220: error: expected primary-expression
> before '->' token
> /home/scottz/stdcxx/include/valarray:2220: error: expected `)' before ';'
> token
> /home/scottz/stdcxx/include/valarray:2220: error: expected `;' before ')'
> token
> /home/scottz/stdcxx/include/valarray:2227: error: 'ERROR' was not declared in
> this scope
> /home/scottz/stdcxx/include/valarray:2227: error: expected `;' before '!'
> token
> /home/scottz/stdcxx/include/valarray:2227: error: expected primary-expression
> before '->' token
> /home/scottz/stdcxx/include/valarray:2227: error: expected `)' before ';'
> token
> /home/scottz/stdcxx/include/valarray:2227: error: expected `;' before ')'
> token
> /home/scottz/stdcxx/include/valarray: In member function
> 'std::valarray<_TypeT>& std::valarray<_TypeT>::operator=(const
> std::mask_array<_TypeT>&)':
> /home/scottz/stdcxx/include/valarray:2238: error: expected unqualified-id
> before '!' token
> /home/scottz/stdcxx/include/valarray:2238: error: expected initializer before
> '!' token
> /home/scottz/stdcxx/include/valarray:2239: error: expected unqualified-id
> before '!' token
> /home/scottz/stdcxx/include/valarray:2239: error: expected initializer before
> '!' token
> /home/scottz/stdcxx/include/valarray:2243: error: 'ERROR' was not declared in
> this scope
> /home/scottz/stdcxx/include/valarray:2243: error: expected `;' before '!'
> token
> /home/scottz/stdcxx/include/valarray:2243: error: expected primary-expression
> before '->' token
> /home/scottz/stdcxx/include/valarray:2243: error: expected `)' before ';'
> token
> /home/scottz/stdcxx/include/valarray:2243: error: expected `;' before ')'
> token
> /home/scottz/stdcxx/include/valarray:2251: error: 'ERROR' was not declared in
> this scope
> /home/scottz/stdcxx/include/valarray:2251: error: expected `;' before '!'
> token
> /home/scottz/stdcxx/include/valarray:2251: error: expected primary-expression
> before '->' token
> /home/scottz/stdcxx/include/valarray:2251: error: expected `)' before ';'
> token
> /home/scottz/stdcxx/include/valarray:2251: error: expected `;' before ')'
> token
>
>
> Yu (Scott) Zhong
>
>