Skip to content

DaemonSnake/gcc-abbreviated-cpp-lambda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gcc-abbreviated-cpp-lambdal

Description

A patch for gcc-7.2 to implement abbreviated lambdas to C++

The patch aims at implementing the proposals:

  • Abbreviated Lambdas for Fun and Profit: P0573r2
  • Forward without forward: P0644r1

Try It

You can try the compiler live [no longer available].

I'm hosting a ubuntu build of the compiler on a Amazon EC2 server and running compiler explorer on it.

Implementation status:

  • adds an abbreviated syntax for lambdas and function/members [OK]
  • uses decltype((ret_expr)) as deduced return type when used [OK]
  • uses noexcept(noexcept(ret_expr)) as deduced exception specification [OK]
  • optional type for lambda's arguments [OK]
  • >>x exacltly equivalent to static_cast<decltype(x)&&>(x) [OK]

Example

[](auto&&x) => func(>>x); /*or*/ [](x) => func(>>x);
//will be equivalent to
[](auto&& x)
  noexcept(noexcept(func(std::forward<decltype(x)&&>(x))))
  -> decltype((func(std::forward<decltype(x)&&>(x))))
{
    return func(std::forward<decltype(x)&&>(x));    
};

template<class T>
constexpr auto f(T&& x) => x; //allowed with functions too

[](x...) {}; //same as [](auto&&... x) {}

How to use localy

Simply run make, sit back and wait. It will:

  • download gcc-7.2
  • apply the patches
  • configure gcc
  • compile gcc
  • install gcc in $(PWD)/gcc/install/
  • compile test.cpp with the new g++.

By default gcc will be configured with the following options:

  • --disable-bootstrap //build gcc using the produced gcc
  • --disable-multilib //cross-compiling
  • --disable-shared //doesn't build shared standard library Simply remove them from the gcc/build command from Makefile if you want to change the default behavior.

About

patches for gcc 7.2 to implement abdriviated lambdas for C++

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published