• Link to Facebook
  • Link to Youtube
DevsClub
  • Home
  • Devs.Hub
    • Devs Resource Hub
    • Color Picker
    • Devs Ai Draw
  • Devs.News
    • AI
    • Design
      • Game design
      • UX Design
    • Development
    • Ethical Hacking
    • Internet
    • Smartphones
    • PC
    • Security
    • Devs Fun Time
  • Devs.Member
  • Free Books
  • Devs.Team
  • Click to open the search input field Click to open the search input field Search
  • Menu Menu
You are here: Home1 / Devs News2 / Dev News3 / Development4 / Εγκρίθηκε η νέα C++20

/Blog

C++20
Εγκριθηκε η νέα C++20

Με την ονομασία C ++ 20, η νέα έκδοση της γλώσσας C ++ έχει λάβει ομόφωνα την τελική τεχνική έγκρισή της , την Παρασκευή 4 Σεπτεμβρίου, από την ομάδα εργασίας που είναι αφιερωμένη σε αυτήν στο πλαίσιο του Διεθνούς Οργανισμού Τυποποίησης (ISO). Σύμφωνα με τον Herb Sutter, μηχανικό της Microsoft και πρόεδρο της επιτροπής ISO C ++, η C ++ 20 θα είναι “η μεγαλύτερη έκδοση της C ++”. Αυτό το νέο πρότυπο γλώσσας, το οποίο ενημερώνεται κάθε 3 χρόνια, είναι πιο σημαντικό από τα προηγούμενα τρία. Eπίσης είναι η πρώτη τυποποιημένη έκδοση.

Νέες δυνατότητες αναμένονται από το C ++ 20

Με την ευκαιρία αυτής της σημαντικής ενημέρωσης της γλώσσας που δημιουργήθηκε το 1980 από τον Δανό επιστήμονα υπολογιστών Bjarne Stroustrup, δύο νέα χαρακτηριστικά έρχονται : modules και coroutines.

Οι coroutines και άλλες δυνατότητες C ++ 20

Οι coroutines είναι λειτουργίες που μπορούν να αναστείλουν και να συνεχίσουν την εκτέλεση τους χωρίς να τροποποιήσουν την κατάστασή τους.  Στόχος τους είναι να γενικεύσουν τη χρήση υπορουτίνων σε μη προληπτικές πολλαπλές εργασίες. Σημειώστε ότι η υποστήριξη για αυτές τις κορουτίνες στην τυπική βιβλιοθήκη έχει προγραμματιστεί για την έκδοση C ++ 23.

Μεταξύ των άλλων νέων δυνατοτήτων που αναμένονται από το C ++ 20, βρίσκουμε επίσης την παρουσία του library synchronization και νέων αλγορίθμων τηλεμετρίας.

Αναλυτικά τα νέα features

New language features

  • Feature test macros
  • 3-way comparison operator <=> and operator==() = default
  • designated initializers
  • init-statements and initializers in range-for
  • char8_t
  • [[no_unique_address]]
  • [[likely]]
  • [[unlikely]]
  • pack-expansions in lambda init-captures
  • removed the requirement to use typename to disambiguate types in many contexts
  • consteval, constinit
  • further relaxed constexpr
  • signed integers are 2’s complement
  • aggregate initialization using parentheses
  • Coroutines
  • Modules
  • Constraints and concepts
  • Abbreviated function templates
  • DR: array new can deduce array size

New library features

Library features

  • Library feature-test macros
  • Formatting library
  • Calendar and Time Zone library
  • source_location
  • span
  • endian
  • array support for make_shared
  • remove_cvref
  • to_address
  • floating point atomics, shared_ptr atomics
  • thread-coordination classes: barrier, latch, and counting_semaphore
  • jthread and thread cancellation classes: stop_token, stop_source, and stop_callback
  • basic_osyncstream
  • u8string and other char8_t uses
  • constexpr for , , 
  • string::starts_with / ends_with and string_view::starts_with / ends_with
  • assume_aligned
  • bind_front
  • c8rtomb/mbrtoc8
  • make_obj_using_allocator etc
  • make_shared_for_overwrite/make_unique_for_overwrite
  • heterogeneous lookup in unordered associative containers
  • polymorphic_allocator with additional member functions and byte as its default template argument
  • execution::unseq
  • midpoint and lerp
  • ssize
  • is_bounded_array, is_unbounded_array
  • Ranges
  • uniform container erasure: std::erase/std::erase_if, e.g. std::erase(std::list) or erase_if(std::map) etc
  • Mathematical constants in 

Παράδειγμα απο την C++20

/**
 @file
 @brief C++20
 @defgroup CPP20 C++20 examples
 [C++20](https://en.wikipedia.org/wiki/C++20)
 [Modern Cpp20 features](https://github.com/AnthonyCalandra/modern-cpp-features/blob/master/CPP20.md)
 https://en.cppreference.com/w/cpp/20
 @{
*/

static_assert(__cplusplus >= 201707);

#include 
#include 
#if __has_include ()
#include 
#endif
#include 
#include 
#include 
#include 
#include 
#include 
#if __cpp_impl_coroutine
#include 
#endif
#include 
#include 
#if __has_include ()
#include 
#endif

using namespace std;

/**
 @defgroup lang20 Language
 [language](https://en.cppreference.com/w/cpp/language)
 @{
 */

#if __cpp_lib_three_way_comparison
static_assert(1 <=> 2 < 0 );
static_assert(2 <=> 1 > 0 );
static_assert(1 <=> 1 == 0 );
#else
#pragma message("undefined __cpp_lib_three_way_comparison")
#endif

#if __cpp_char8_t
/// [char8_t](https://en.cppreference.com/w/cpp/keyword/char8_t)
char8_t char8;
#endif

/// [to_array](https://en.cppreference.com/w/cpp/container/array/to_array)

auto to_array_demo = experimental::to_array("foo");
static_assert(to_array_demo.size() == 4);

void init_20()
{
	struct point { int x, y; };
	struct line { point a, b; };

	// [aggregate_initialization](https://en.cppreference.com/w/cpp/language/aggregate_initialization)

#if __cplusplus > 201707
	point p1 = { .x = 1 };
	assert(p1.x == 1);
	assert(!p1.y);

	point p2 { {} , 2 };
	assert(p2.y == 2);
	assert(!p2.x);
#endif
#if __cpp_aggregate_paren_init >= 201902
	int a[] (0, 1, 2);
	assert(a[2] == 2);
	line l2 = { 1, 2 };
	assert(l2.a.x == 1);
	assert(l2.a.y == 2);
#endif
	line l1 = { };
	assert(!l1.a.x);
	line l3 = { 1, 2, 3, 4 };
	assert(l3.b.x == 3);
	assert(l3.b.y == 4);
}

void types_20()
{
#if __cpp_lib_bit_cast
	cout << typeid(bit_cast(0));
#endif
}

void dynamic_memory_20()
{
	/// Shared array
	/// [make_shared](https://en.cppreference.com/w/cpp/memory/shared_ptr/make_shared)
	auto a = make_shared();
	static_assert(is_same_v);

	/// [contains](https://en.cppreference.com/w/cpp/container/map/contains)
	map m = {{2,3}};
#if __cplusplus > 201707 && __GNUG__ > 8
	assert(m.contains(2));
#endif
#if __cpp_lib_erase_if
	/// [erase_if](https://en.cppreference.com/w/cpp/container/map/erase_if)
	vector v = {11, 12, 13};
	assert(erase_if(v, [](int a) {return a >= 13;}) == 1);
	assert(v.size() == 2);
#endif
}

namespace lambda {

#if __cpp_template_template_args && __GNUG__ > 8
/// [Lambda capture of parameter pack](https://en.cppreference.com/w/cpp/language/lambda#Lambda_capture)
template 
auto make_lambda_with_parameter_pack_capture(Args&& ... args)
{
	return [... args = forward(args)] {
		return (... + args);
	};
}
#endif

void lambda_20()
{
#if __cplusplus >= 201709
	// generic lambda, operator() is a template with two parameters
	auto glambda = [](T a, auto&& b) { return a < b; };
	assert(glambda(1,2));
	// generic lambda, operator() is a template with one parameter pack
	auto f = [](Ts&& ...ts) {
		return 1;
	};
	assert(f(1,2,3));

	struct point { int x, y; };
	auto point_lambda = [](T&& var) {};
	point_lambda({1, 2});

	#if __cpp_template_template_args && __GNUG__ > 8
	assert(make_lambda_with_parameter_pack_capture(1,2,3)() ==  6);
	#endif
#endif
}

}
using namespace lambda;


/// @} lang20

/**
 @defgroup templ20 Template
 [templates](https://en.cppreference.com/w/cpp/language/templates)
 @{
*/

#if __cpp_concepts
/**
 @}
 @defgroup conc20 Concepts
 https://en.wikipedia.org/wiki/Concepts_(C++)
 [constraints](https://en.cppreference.com/w/cpp/language/constraints)
 [concepts](https://en.cppreference.com/w/cpp/header/concepts)
 @{
*/

/**
 @defgroup req20 'Requires' clause and expression
 @{
*/

// Using [requires](https://en.cppreference.com/w/cpp/keyword/requires)

template  requires is_integral_v T constexpr requires_demo(T a) { return a + 1; }

static_assert(requires_demo(1) == 2);

/**
  requires-clause can be after function declaration and supports template overloading
 */

template  auto constexpr requires_demo(T && a) requires is_same_v { return 2; }
static_assert(requires_demo(0.1) == 2);

// Annotated example of complex requirement
template 
requires // requires-clause
is_signed_v || (is_unsigned_v && ! is_void_v) // constraint expression
void complex_requirement_demo() { }

/// Annotated example of requires-expression

template < class T >
requires  // requires-clause
requires() // requires-expression
{ true;} // unevaluated requirements sequence
void requires_expression_demo() { }

template  requires requires(T a) { a / 0; } auto constexpr what(T a) { return 1; }
static_assert(what(1) == 1);

template  requires requires(T a) { a[0]; } auto constexpr what(T a) { return 2; }
static_assert(what("2") == 2);

/// @}


/**
 @defgroup conc_def_20 Concept definitions
 @{
 */

/// trivial concepts as assignment
template  concept truism = true;

#if !__cpp_lib_concepts

/// short concept definition from a constraint directly
template  concept integral = is_integral_v;

#endif

/**
  defining concept with requires-expression
 */

template  concept integral_req_ct = requires (T a) { is_integral_v; };

template  constexpr T _inc2(T a) { return a + 1; }

static_assert(_inc2(1) == 2);

/**
  [Compound_Requirements](https://en.cppreference.com/w/cpp/language/constraints#Compound_Requirements)
  [convertible_to](https://en.cppreference.com/w/cpp/concepts/convertible_to)
 */

template concept compound_requirements =
requires(T x) {
	{x + 1} -> convertible_to;
	{x * 2} -> same_as;
};



/// @}

/// @}
#else
#pragma message("undefined __cpp_concepts")
#endif

/**
 @defgroup cor20 Coroutines
 @{
	[coroutine](https://en.cppreference.com/w/cpp/coroutine)
	[coroutines](https://en.cppreference.com/w/cpp/language/coroutines)
 */

#if __cpp_impl_coroutine
auto switch_to_new_thread(jthread& out)
{
	struct awaitable {
		jthread* p_out;
		bool await_ready() { return false; }
		void await_suspend(coroutine_handle<> h) {
			jthread& out = *p_out;
			if (out.joinable())
				throw runtime_error("Output jthread parameter not empty");
			out = jthread([h] { h.resume(); });
		}
		void await_resume() {}
	};
	return awaitable{&out};
}

struct task {
	struct promise_type {
		struct task get_return_object() { return {}; }
		suspend_never initial_suspend() { return {}; }
		suspend_never final_suspend() noexcept { return {}; }
		void return_void() {}
		void unhandled_exception() {}
	};
};

struct task resuming_on_new_thread(jthread& out)
{
	auto starting_tid = this_thread::get_id();
	// suspends coroutine
	co_await switch_to_new_thread(out); ///< [co_await](https://en.cppreference.com/w/cpp/keyword/co_await)
	// awaiter is destroyed here
	assert(this_thread::get_id() != starting_tid);
}

void coroutine_demo()
{
	jthread out;
	resuming_on_new_thread(out);
}
#else
void coroutine_demo() {}
#pragma message("undefined __cpp_impl_coroutine")
#endif
/// @}

/**
 @defgroup other20 Other
 @{
  TODO:
  [range-for](https://en.cppreference.com/w/cpp/language/range-for)
 */

#if __cpp_lib_ranges

#include 

/// [ranges](https://en.cppreference.com/w/cpp/ranges)

struct ranges_20 {
	ranges_20() {
		auto data = {0, 1, 2, 3};
		/// [reverse_view](https://en.cppreference.com/w/cpp/ranges/reverse_view)
#if __clang_major__ != 10
		ranges::reverse_view rv {data};
		auto r = data | views::reverse;
		// r is kind of transform_view
		vector result(r.begin(), r.end());
		assert(vector(rv.begin(), rv.end()) == result);
		assert((result == vector{3, 2, 1, 0}));
#endif
	}
} ranges_20;

#else
#pragma message("undefined __cpp_lib_ranges")
#endif

#include 

/// [source_location](https://en.cppreference.com/w/cpp/utility/source_location)

struct location_20 {
	location_20() {
		auto l = experimental::source_location::current();
		basic_stringstream buff;
		buff << l.file_name() << ":" << l.line() << ":" << l.column() << l.function_name();
		assert(buff.str().length());
	}
} location_20;

/**
 [functional](https://en.cppreference.com/w/cpp/header/functional)
 */

void functional_20()
{
	/// [bind_front](https://en.cppreference.com/w/cpp/utility/functional/bind_front)
	auto constexpr plus_one = std::bind_front(std::plus(), 1);
	static_assert(plus_one(2) == 3);
}

/// @} other20

int main()
{
	init_20();
	types_20();
	dynamic_memory_20();
	lambda_20();
#if __cpp_lib_jthread
	jthread t([]{ });
#endif
	coroutine_demo();
	functional_20();
}
/// @}

/**
 @mainpage
 @ref CPP20
 @ref CPP17
 @ref CPP14
 @ref CPP11
 @ref CPP03
*/

Check this out…

Grok-4 is unleashed.

Grok 4 Unleashed: Elon Musk’s ‘Smartest AI’ Hits Tesla

Read more
https://www.devsclub.gr/wp-content/uploads/2025/07/Grok-4.webp 1024 1536 Domi https://www.devsclub.gr/wp-content/uploads/2020/01/DC.png Domi2025-07-14 10:35:202025-07-14 10:35:20Grok 4 Unleashed: Elon Musk’s ‘Smartest AI’ Hits Tesla
software3: AI as OS

Όταν η Τεχνητή Νοημοσύνη Γίνεται το Επόμενο Λειτουργικό Σύστημα

Read more
https://www.devsclub.gr/wp-content/uploads/2025/06/software3_AI_OS.webp 1024 1536 Domi https://www.devsclub.gr/wp-content/uploads/2020/01/DC.png Domi2025-06-21 19:30:052025-06-21 19:30:05Όταν η Τεχνητή Νοημοσύνη Γίνεται το Επόμενο Λειτουργικό Σύστημα

New AI business Service: Google Agentspace

Read more
https://www.devsclub.gr/wp-content/uploads/2025/02/2025-02-24_10h36_06.png 417 743 Domi https://www.devsclub.gr/wp-content/uploads/2020/01/DC.png Domi2025-02-24 10:45:572025-02-24 10:48:06New AI business Service: Google Agentspace
About iOS 18 Image

iOS 18: Ανακαλύπτοντας τις Νέες Δυνατότητες και Προσαρμογές

Read more
https://www.devsclub.gr/wp-content/uploads/2024/09/DALL·E-2024-09-17-10.08.47-A-vibrant-and-sleek-promotional-image-for-an-article-about-iOS-18.-The-image-features-an-iPhone-with-a-dynamic-home-screen-showcasing-customizable-app-1.webp 1024 1792 Domi https://www.devsclub.gr/wp-content/uploads/2020/01/DC.png Domi2024-09-17 11:10:272024-09-17 11:20:36iOS 18: Ανακαλύπτοντας τις Νέες Δυνατότητες και Προσαρμογές

Η Ευρωπαϊκή Ένωση Ερευνά τις Συμφωνίες Τεχνητής Νοημοσύνης

Read more
https://www.devsclub.gr/wp-content/uploads/2024/07/2024-07-11_18h54_10.png 686 1040 Domi https://www.devsclub.gr/wp-content/uploads/2020/01/DC.png Domi2024-07-11 19:26:042024-07-11 19:29:50Η Ευρωπαϊκή Ένωση Ερευνά τις Συμφωνίες Τεχνητής Νοημοσύνης

From Diagram to Code: 100% AI-Generated Process AND FREE

Read more
https://www.devsclub.gr/wp-content/uploads/2024/02/a7e92e7c-f3e2-4f68-8da5-92d7335714cf.jpg 1024 1024 Domi https://www.devsclub.gr/wp-content/uploads/2020/01/DC.png Domi2024-02-15 00:58:362024-02-15 01:00:33From Diagram to Code: 100% AI-Generated Process AND FREE

AutoGPT: The Revolutionary Tool Powered by GPT-4

Read more
https://www.devsclub.gr/wp-content/uploads/2023/04/AutoGPT-1.png 1108 1990 Domi https://www.devsclub.gr/wp-content/uploads/2020/01/DC.png Domi2023-04-29 03:48:532023-04-29 17:31:16AutoGPT: The Revolutionary Tool Powered by GPT-4

New Job Arrived: Discover the Versatile Role of Prompt Engineering Across Industries Using AI Solutions

Read more
https://www.devsclub.gr/wp-content/uploads/2023/04/Leonardo_Diffusion_Artificial_Intelligence_new_Jobs_2.jpg 1024 1024 Domi https://www.devsclub.gr/wp-content/uploads/2020/01/DC.png Domi2023-04-16 21:56:092023-04-16 22:45:35New Job Arrived: Discover the Versatile Role of Prompt Engineering Across Industries Using AI Solutions
Gupta's AI Model

Engineering student’s AI model turns American Sign Language into English in real-time

Read more
https://www.devsclub.gr/wp-content/uploads/2023/03/2023-03-22_16h07_21.png 670 1196 Domi https://www.devsclub.gr/wp-content/uploads/2020/01/DC.png Domi2023-03-22 16:24:132023-03-22 16:42:38Engineering student’s AI model turns American Sign Language into English in real-time
Previous Previous Previous Next Next Next
Share this entry
  • Share on Facebook
  • Share on X
  • Share on WhatsApp
  • Share on Pinterest
  • Share on LinkedIn
  • Share on Tumblr
  • Share on Vk
  • Share on Reddit
  • Share by Mail

Devs Latest news

  • Grok-4 is unleashed.
    Grok 4 Unleashed: Elon Musk’s ‘Smartest AI’ Hits Tesla
  • software3: AI as OS
    Όταν η Τεχνητή Νοημοσύνη Γίνεται το Επόμενο Λειτουργικό Σύστημα
  • New AI business Service: Google Agentspace
  • About iOS 18 Image
    iOS 18: Ανακαλύπτοντας τις Νέες Δυνατότητες και Προσαρμογές
  • Η Ευρωπαϊκή Ένωση Ερευνά τις Συμφωνίες Τεχνητής Νοημοσύνης

Categories

Archives

  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • September 2024
  • July 2024
  • February 2024
  • January 2024
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • October 2021
  • September 2021
  • August 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
DevsTeam | © Copyright - DevsClub
  • Link to Facebook
  • Link to Youtube
Scroll to top Scroll to top Scroll to top

This site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.

Accept settingsHide notification onlySettings

Cookie and Privacy Settings



How we use cookies

We may request cookies to be set on your device. We use cookies to let us know when you visit our websites, how you interact with us, to enrich your user experience, and to customize your relationship with our website.

Click on the different category headings to find out more. You can also change some of your preferences. Note that blocking some types of cookies may impact your experience on our websites and the services we are able to offer.

Essential Website Cookies

These cookies are strictly necessary to provide you with services available through our website and to use some of its features.

Because these cookies are strictly necessary to deliver the website, refusing them will have impact how our site functions. You always can block or delete cookies by changing your browser settings and force blocking all cookies on this website. But this will always prompt you to accept/refuse cookies when revisiting our site.

We fully respect if you want to refuse cookies but to avoid asking you again and again kindly allow us to store a cookie for that. You are free to opt out any time or opt in for other cookies to get a better experience. If you refuse cookies we will remove all set cookies in our domain.

We provide you with a list of stored cookies on your computer in our domain so you can check what we stored. Due to security reasons we are not able to show or modify cookies from other domains. You can check these in your browser security settings.

Google Analytics Cookies

These cookies collect information that is used either in aggregate form to help us understand how our website is being used or how effective our marketing campaigns are, or to help us customize our website and application for you in order to enhance your experience.

If you do not want that we track your visit to our site you can disable tracking in your browser here:

Other external services

We also use different external services like Google Webfonts, Google Maps, and external Video providers. Since these providers may collect personal data like your IP address we allow you to block them here. Please be aware that this might heavily reduce the functionality and appearance of our site. Changes will take effect once you reload the page.

Google Webfont Settings:

Google Map Settings:

Google reCaptcha Settings:

Vimeo and Youtube video embeds:

Other cookies

The following cookies are also needed - You can choose if you want to allow them:

Privacy Policy

You can read about our cookies and privacy settings in detail on our Privacy Policy Page.

Privacy Policy
Accept settingsHide notification only