/ home / Programming / C++ / Proposals /

C++ Proposal

Let @ become a synonymn for this->.

Would this offer any new functionality? §
Then what is the point? §
Why not use nothing instead? §
Is this-> used particularly often? §
Is it really that big of a deal? §
  1. // Example found searching through searching through system source files:
  2. TYPED_TEST(StorageCache, AddFilePaths)
  3. {
  4. /* this */
  5. auto ids = this->cache.ids( { this->filePath1, this->filePath2, this->filePath3, this->filePath4 } );
  6. ASSERT_THAT( ids, ElementsAre( this->id1, this->id2, this->id3, this->id4 ) );
  7. /* vs @ */
  8. auto ids = @cache.ids( { @filePath1, @filePath2, @filePath3, @filePath4 } );
  9. ASSERT_THAT( ids, ElementsAre( @id1, @id2, @id3, @id4 ) );
  10. /* vs nothing */
  11. auto ids = cache.ids( { filePath1, filePath2, filePath3, filePath4 } );
  12. ASSERT_THAT( ids, ElementsAre( id1, id2, id3, id4 ) );
  13. }
Benefits? §
Drawbacks? §
Alternatives? §
  1. TYPED_TEST(StorageCacheAddFilePaths)
  2. {
  3. auto ids = .cache.ids( { .filePath1, .filePath2, .filePath3, .filePath4 } );
  4. ASSERT_THAT( ids, ElementsAre( .id1, .id2, .id3, .id4 ) );
  5. }
Final thoughts §
Thank you for your time and consideration.