--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
Namespaces differ from classes in that they can be split within and amongst translation units. The definition of a namespace is not required to be the same in different translation units. Multiple namespace definitions of the same namespace in the same translation unit are logically merged into one (the first is called the original, the following are called extensions).How do template namespace specialization and template namespace instantiation interact with these new properties that are not present in other template entities?Also namespaces can contain the following declarations, whereas classes cannot:explicit-instantiationexplicit-specializationlinkage-specificationnamespace-definitionattribute-declarationasm-definitionnamespace-alias-definitionusing-directiveopaque-enum-declarationNow that all these are possible member declarations of a template entity, how are they handled?Also you need to think about program initialization. The members of a namespace have a bunch of rules about when they are initialized and in what order. How will these rules interact with template namespace instances?The best approach for this type of feature would be to put together an experimental compiler extension to gcc or clang that implements template namespaces. This would shake out all the above issues (and likely more) which you could then use as the basis of a proposal.
On Sunday, January 19, 2014 6:26:57 PM UTC+1, dgutson . wrote:Hi.I found a number of situations where the ability to templetize namespaces would be very useful.My latest use case is this: I'm writing a library that is configured through a number of (non-type) template arguments. Such configuration affects to all the classes of the library. To be more specific, it's a fault-tolerant library for the aerospace industry where the whole library is tuned with some integers (some of then related to redundancy due to ionizing radiation).The most natural thing would be to put all the classes in a namespace, and let the namespace be templetized with such arguments.Moreover, a using namespace with the appropriate arguments would suffice for all the application. For example:using namespace TheLibrary<arg1, arg2, arg3>;I didn't write the proposal yet, since I'd like to get some feedback.
Thanks,Daniel.ps: The library will be available soon and uses template metaprogramming based on the arguments.--
Who’s got the sweetest disposition?
One guess, that’s who?
Who’d never, ever start an argument?
Who never shows a bit of temperament?
Who's never wrong but always right?
Who'd never dream of starting a fight?
Who get stuck with all the bad luck?
--
Namespaces differ from classes in that they can be split within and amongst translation units. The definition of a namespace is not required to be the same in different translation units. Multiple namespace definitions of the same namespace in the same translation unit are logically merged into one (the first is called the original, the following are called extensions).How do template namespace specialization and template namespace instantiation interact with these new properties that are not present in other template entities?Also namespaces can contain the following declarations, whereas classes cannot:explicit-instantiationexplicit-specializationlinkage-specificationnamespace-definitionattribute-declarationasm-definitionnamespace-alias-definitionusing-directiveopaque-enum-declarationNow that all these are possible member declarations of a template entity, how are they handled?Also you need to think about program initialization. The members of a namespace have a bunch of rules about when they are initialized and in what order. How will these rules interact with template namespace instances?
The best approach for this type of feature would be to put together an experimental compiler extension to gcc or clang that implements template namespaces. This would shake out all the above issues (and likely more) which you could then use as the basis of a proposal.
On Sunday, January 19, 2014 6:26:57 PM UTC+1, dgutson . wrote:Hi.I found a number of situations where the ability to templetize namespaces would be very useful.My latest use case is this: I'm writing a library that is configured through a number of (non-type) template arguments. Such configuration affects to all the classes of the library. To be more specific, it's a fault-tolerant library for the aerospace industry where the whole library is tuned with some integers (some of then related to redundancy due to ionizing radiation).The most natural thing would be to put all the classes in a namespace, and let the namespace be templetized with such arguments.Moreover, a using namespace with the appropriate arguments would suffice for all the application. For example:using namespace TheLibrary<arg1, arg2, arg3>;I didn't write the proposal yet, since I'd like to get some feedback.Thanks,Daniel.ps: The library will be available soon and uses template metaprogramming based on the arguments.--
Who’s got the sweetest disposition?
One guess, that’s who?
Who’d never, ever start an argument?
Who never shows a bit of temperament?
Who's never wrong but always right?
Who'd never dream of starting a fight?
Who get stuck with all the bad luck?
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
What are the shortcomings of using a class template as a poor-man's template?
I imagine that the first one is that it must be defined in a single header, so if the amount of code used internally is large enough it could make it hard to maintain.
The syntax looks like a using-directive, do you also wish for the lookup changes associated with it?
I imagine this to be the case, right? Can you use the same library in one program with different template arguments?
Can you provide a small code sample with how it would look like?
On Sun, Jan 19, 2014 at 10:16 AM, Andrew Tomazos <andrew...@gmail.com> wrote:
Namespaces differ from classes in that they can be split within and amongst translation units. The definition of a namespace is not required to be the same in different translation units. Multiple namespace definitions of the same namespace in the same translation unit are logically merged into one (the first is called the original, the following are called extensions).How do template namespace specialization and template namespace instantiation interact with these new properties that are not present in other template entities?Also namespaces can contain the following declarations, whereas classes cannot:explicit-instantiationexplicit-specializationlinkage-specificationnamespace-definitionattribute-declarationasm-definitionnamespace-alias-definitionusing-directiveopaque-enum-declarationNow that all these are possible member declarations of a template entity, how are they handled?Also you need to think about program initialization. The members of a namespace have a bunch of rules about when they are initialized and in what order. How will these rules interact with template namespace instances?The best approach for this type of feature would be to put together an experimental compiler extension to gcc or clang that implements template namespaces. This would shake out all the above issues (and likely more) which you could then use as the basis of a proposal.In addition to the above list, a proposal on this would need to consider whether namespace templates could support explicit specializations, partial specializations, and explicit instantiations (both for themselves and for their members).
I had the exact same ideas few months ago after finding myself doing generic library which all types would depend on the same type,and remarking how much duplication could be avoided if I was allowed to specify that a whole bunch of types would automatically have an additional template parameter implicitly.namespace blah< typename X >{class K {};template < class T > class U {};}would be translated tonamespace blah{template< typename X >class K {};template< typename X, class T > class U {};}However, after weeks of thinking about this I concluded that:1. namespace are not the appropriate construct for this, they really are too different and not really encapsulating anything than names;2. there are a lot of potential issues related to the order of template arguments;
3. there is a potential issue for reading the code as you need to see the namespace declaration before being able to follow the rest of the code.
What I mean here is basically the same argument that makes Clang developers avoid anonymous namespaces.Also, I believe that the real thing I do want when I'm writing these generic libraries is actually to generate a whole bunch of types, using another type as argument of the process to generate the wanted types.
Basically, I want one of the features that the Reflection group is supposed to look for.
Since that realization, I think that efforts should be put to have a new reflection construct instead of making namespace do something too different from it's initial use.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
On Wed, Jan 22, 2014 at 9:47 AM, Klaim - Joël Lamotte <mjk...@gmail.com> wrote:
I had the exact same ideas few months ago after finding myself doing generic library which all types would depend on the same type,and remarking how much duplication could be avoided if I was allowed to specify that a whole bunch of types would automatically have an additional template parameter implicitly.namespace blah< typename X >{class K {};template < class T > class U {};}would be translated tonamespace blah{template< typename X >class K {};template< typename X, class T > class U {};}However, after weeks of thinking about this I concluded that:1. namespace are not the appropriate construct for this, they really are too different and not really encapsulating anything than names;2. there are a lot of potential issues related to the order of template arguments;Please elaborate about the last two points.
3. there is a potential issue for reading the code as you need to see the namespace declaration before being able to follow the rest of the code.I don't find this issue different than any other template declaration, for example a nested class of a template class.
template<typename Typename>
class A{
namespace B{
Typename Variable;
}
};