Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++11-based grammar needs #21

Open
daoswald opened this issue Aug 28, 2014 · 0 comments
Open

C++11-based grammar needs #21

daoswald opened this issue Aug 28, 2014 · 0 comments

Comments

@daoswald
Copy link
Owner

We should begin supporting:

struct SomeType {
SomeType() = default; //The default constructor is explicitly stated.

struct NonCopyable {
NonCopyable() = default;
NonCopyable(const NonCopyable&) = delete;

For methods marked 'delete', we should probably assure these are not picked up by Inline::CPP. Those marked 'default' we should detect and pick up, and then let C++ do the right thing.

We must also make sure to not interfere with pure virtuals (Currently I think this works, so we should do no harm):

struct Interface {
~Interface() = 0;

Uniform Type Initialization:

struct AltStruct {
AltStruct(int x, double y) : x_{x}, y_{y} {}

Alternative Function Syntax

template<class Lhs, class Rhs>
auto adding_func(const Lhs &lhs, const Rhs &rhs) -> decltype(lhs+rhs) {return lhs + rhs;}

....or nominally (without templates)....

auto add ( int a, int b ) -> decltype(a+b) { return a + b; }

Constant expressions:

constexpr int get_five() {return 5;}
constexpr double earth_gravitational_acceleration = 9.8;

Explicit keyword:

class SomeClass {
public:
SomeClass() {}
explicit SomeClass(int new_value) : value(new_value) {}

Override and Final:

struct Derived : Base {
virtual void some_func(int) override; // ill-formed - doesn't override a base class method
};

struct Base1 final { };

struct Derived1 : Base1 { }; // ill-formed because the class Base1 has been marked final
struct Base2 {
virtual void f() final;
};

Enum class:

enum class Enumeration {
Val1,
Val2,
Val3 = 100,
Val4 // = 101
};

'explicit' type modifier:

explicit SomeClass(int new_value) : value(new_value) {}

long long int

long long int a { 1000 };
long long int a;
long long int a = 100;
long long int a(100);

(Minimum width is 64b)

In many cases we simply need to allow for these constructs in the grammar, and then rely on C++ doing the right thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant