Skip to main content
1-Visitor
Jan 12, 2024 7:44 AM UTC
Acknowledged

Officially support standards C++17 and C++20 for Object TOOLKIT C++

Related products:Creo Parametric

1. What product and version are you running?


We are currently working with Creo Parametric 7.0.12.0.


2. What is the problem?


According to the PTC article CS323813, the C++ standards C++17 and C++20 are currently not officially supported, only C++14.

Here's a list of some C++ features that can't be used today:

 

C++17 Features

  • Structured Bindings: Allows the decomposition of objects into their components, simplifying variable declarations.
  • std::optional: For representing optional values, similar to "Nullable" types in other languages.
  • Inline Variables: Solve the issue of multiple definitions across different translation units.
  • std::variant and std::any: Type-safe unions for storing values of different types.
  • If and Switch with Initializers: Enables the declaration of a variable within the condition of if and switch statements.
  • Fold Expressions: For more elegant handling of variadic templates.
  • Filesystem Library: Introduction of a standardized API for working with file systems.

C++20 Features

  • Concepts: Provide a way to express template requirements more clearly and understandably.
  • Ranges Library: Extends the capabilities of STL algorithms by introducing range operations.
  • Coroutines: Support for coroutines, enabling more efficient and simpler handling of asynchronous code.
  • Modules: Reduce the need for headers and preprocessor directives, improve compile times and code modularity.
  • Lambdas with Default Constructor: Allow the use of capture-less lambdas as regular functions.
  • Constant Evaluation for Certain Functions: Allows more code to be executed at compile time, which can improve runtime efficiency.
  • std::format: A safer and more flexible alternative to printf for string formatting.

 

3. Are you using a workaround? If yes, please describe it.


The restriction to C++ features of a maximum of C++14 and the use of various 3rd party libraries.

4. What is the use case for your organization? Describe how your idea would work in context or how it would apply to a practical situation.

 

The new features introduced in C++17 and C++20 bring several significant advantages to C++ development, enhancing both the language's capabilities and the developer experience. Here's an overview of the major advantages:

 

Advantages of C++17 Features

  • Simpler and More Readable Code: Structured bindings and if/switch with initializers contribute to more concise and readable code.
  • Improved Type Safety and Expressiveness: std::optional, std::variant, and std::any enhance type safety and expressiveness, allowing for more robust and clear code.
  • Better Resource Management: Features like std::optional reduce the need for raw pointers, thereby improving memory safety.
  • Enhanced Compile-Time Processing: Inline variables and constexpr if improve template metaprogramming and reduce compile-time dependencies.
  • Standardized Filesystem Handling: The filesystem library standardizes file operations, making code more portable and reducing reliance on third-party libraries.
  • Modern Template Features: Fold expressions and other template improvements simplify complex template programming.

Advantages of C++20 Features

  • More Efficient and Readable Templates: Concepts significantly improve template readability and debugging, making templates easier to use and understand.
  • Enhanced Range-Based Operations: The Ranges library provides more powerful and intuitive ways to process sequences of data.
  • Support for Asynchronous Programming: Coroutines facilitate asynchronous and concurrent programming, allowing for more efficient handling of tasks that involve waiting or polling.
  • Improved Compilation and Module Management: Modules enhance compilation speed and improve code organization, reducing header dependencies and compile times.
  • Advanced Lambda Expressions: Extended lambda capabilities, including lambdas with default constructors, allow for more flexible and powerful functional programming patterns.
  • More Runtime Efficiency: Constant evaluation features allow for more computations to be moved to compile time, potentially improving runtime performance.
  • Safe and Flexible String Formatting: std::format provides a type-safe and more flexible alternative to traditional C-style string formatting functions.

Overall, these advancements in C++17 and C++20 contribute to making C++ a more modern, efficient, and user-friendly programming language. They address many of the historical pain points in C++ programming, such as complex template syntax, inefficient string handling, and cumbersome file operations, thereby enhancing both the performance of C++ applications and the productivity of developers.

 

5. What impact does this problem currently have on your organization? (Number of users affected, hours of lost productivity, etc.)

About a dozen people who use the TOOLKIT interface at our company are affected.

5 replies

Jan 12, 2024 9:11 AM UTC
Status changed to: Acknowledged

Hi @DomenicLaritz!

Thank you for your idea. Based on the information you provided, we are acknowledging it as the Community management team. This is not a commitment from the Product team. Other users may comment and vote your idea up.

Jan 23, 2024 12:07 PM UTC

Yeah, this should be a nice add-on for WinRT GUI development with Creo Parametric Toolkit / Object Toolkit for C++

Oct 9, 2024 12:55 PM UTC

Let's start with changing macro "#define optional" to "#define pfcOptionalIndicator". In this way, even in C++14 with boost you will be able to access boost::optional.  

Mar 19, 2025 11:32 AM UTC

Yup, those two things sucks.  

 

# define optional

which obviously is in conflict with std::optional 

 

Second a bit strange approach we may find in: cipxobj.h and xstring.h both at line 17

using namespace std;

 

https://community.ptc.com/t5/Customization/Object-Toolkit-C-standard-and-its-violations/m-p/1003974#M13882

Mar 19, 2025 11:40 AM UTC

3. Are you using a workaround? If yes, please describe it. 

We store creo api heder files in our repo and getting rid of # define optional. Then all "optional " / in PTC code are replaced by space and we are able to compile even with C++23 and all beauty of that standard like ranges or filesystem. 

We have a plan to try close Creo API in C++ module, however this require more investigation and not sure if it blocks all unwanted ptc non standard features.