struct Base
{
int x;
int arr[2];
void foo(int,char){}
};
struct Derived : Base
{
void foo(float){}
std::pair<char,char> p;
using y = x; // add alias for 'x' member
using a1 = a[1];
using f1 = foo(int,char);
using g2 = foo(float);
using p2 = p.second;
};
Base b;
Derived d;
d.x = 10; // ok
d.y = 20; // ok, the same as 'd.x =20'
b.y = 30; // error, 'y' defined only for 'Derived'
d.f1(100,'a'); // call foo(int,char)
d.f2(3.14);// call foo(float)
d.p2 ='q'; // d.p.second ='q'
In large programs with hundreds and thousands of classes in inheritance hierarchy, it is maybe useful for clarification of semantic of some variables and methods. Using of alias names will narrow the search to those names for the project. For example, field 'name' in root class could be aliased as 'name_car', 'name_aircraft', 'name_ship' etc.
In large programs with hundreds and thousands of classes in inheritance hierarchy, it is maybe useful for clarification of semantic of some variables and methods. Using of alias names will narrow the search to those names for the project. For example, field 'name' in root class could be aliased as 'name_car', 'name_aircraft', 'name_ship' etc.
Hello! I want to create aliases for any names in program (not only types and templates). I propose to use "using" keyword for this. For example:
struct Base
{
int x;
int arr[2];
void foo(int,char){}
};
struct Derived : Base
{
void foo(float){}
std::pair<char,char> p;
using y = x; // add alias for 'x' member
using a1 = a[1];
using f1 = foo(int,char);
using g2 = foo(float);
using p2 = p.second;
};
Base b;
Derived d;
d.x = 10; // ok
d.y = 20; // ok, the same as 'd.x =20'
b.y = 30; // error, 'y' defined only for 'Derived'
d.f1(100,'a'); // call foo(int,char)
d.f2(3.14);// call foo(float)
d.p2 ='q'; // d.p.second ='q'In large programs with hundreds and thousands of classes in inheritance hierarchy, it is maybe useful for clarification of semantic of some variables and methods. Using of alias names will narrow the search to those names for the project. For example, field 'name' in root class could be aliased as 'name_car', 'name_aircraft', 'name_ship' etc.
--
---
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 Mon, May 18, 2015 at 9:54 AM, Yuriy Smirnov <neoprog...@gmail.com> wrote:Hello! I want to create aliases for any names in program (not only types and templates). I propose to use "using" keyword for this. For example:
struct Base
{
int x;
int arr[2];
void foo(int,char){}
};
struct Derived : Base
{
void foo(float){}
std::pair<char,char> p;
using y = x; // add alias for 'x' member
using a1 = a[1];How is this supposed to be parsed? We don't know the type of 'this' here. Consider:
As well as without aliases.
(1) In our codebase, class functions are PascalCase'd (IsEmpty, Resize, GetSize, GetData...), but it's also common to want to compatibility with STL containers and genericity in template algorithms. This leaves us declaring methods (empty, resize, size, data...) that are just dumb forwarders to the real call. IsEmpty and empty are not different functions though
On Jun 7, 2015 11:17 AM, "Nevin Liber" <ne...@eviloverlord.com> wrote:
>
> On 7 June 2015 at 13:00, Jim Porter <jvp...@g.rit.edu> wrote:
>>
>> When I'm inside a function and want to use
>> a function like `make_thing_with_a_very_long_name` several times, it would be useful to be able to alias it to something shorter.
>
>
> Why not use a lambda for this?
Can you have variadic lambdas now? Otherwise, you have to painstakingly respecify much of the signature to forward.
Also, they'd still be more heavyweight machinery than necessary for an alias.
Also also, how would lambdas here interact with refactoring tool support? Tools could see through aliases easily, but seeing through forwarding wrappers has so far been problematic (there's a lack of semantic information that forwarding is the function's intent or purpose).
Also^3, why not just use a macro? *ducks*
> --
> Nevin ":-)" Liber <mailto:ne...@eviloverlord.com> (847) 691-1404
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the Google Groups "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this topic, visit https://groups.google.com/a/isocpp.org/d/topic/std-proposals/MkopUDw0JhU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to std-proposal...@isocpp.org.
class Foo {
int a;
public:
using(const int) b = a;
// etc...
};
using(type) name = expr;
struct Bar {
int x, y, z;
};
int bar_equals(Bar*, Bar*);
using(bool Bar::*bar) operator==(const Bar& other) = bar_equals(bar, &other);
void func(FILE* hnd) {
raii_closer endofscope{hnd};
using raii_closer=; // "Undeclare raii_closer"
}