junjieg Posted April 30, 2020 Report Share Posted April 30, 2020 Per 1.0a release the grammar of range in c++ syntax is implemented without template, however the examples showed us that sometimes we can use it with template, sometimes we can use it without template, are the examples which using with template incorrect or not? see below for details: range header definition in annex C.36, define it without template =========================================================== C.36 File pss/range.h #pragma once #include <vector> #include "pss/detail/rangeBase.h" namespace pss { class Lower { public: }; // Used to specify a range that is bounded // by the domain minimum const Lower lower; class Upper { public: }; // Used to specify a range that is bounded // by the domain maximum const Upper upper; /// Declare domain of a numeric scalar attribute class range : public detail::RangeBase { public: /// Declare a range of values range (const detail::AlgebExpr& lhs, const detail::AlgebExpr& rhs); range (const Lower& lhs, const detail::AlgebExpr& rhs); range (const detail::AlgebExpr& lhs, const Upper& rhs); /// Declare a single value range (const detail::AlgebExpr& value); /// Copy constructor range ( const range& a_range); /// Function chaining to declare another range of values range& operator() (const detail::AlgebExpr& lhs, const detail::AlgebExpr& rhs); /// Function chaining to declare another single value range& operator() (const detail::AlgebExpr& value); }; // class range }; // namespace pss =========================================================== examples without template 8.1.3 Examples =========================================================== 8.1.3 Examples The DSL and C++ scalar data examples are shown in-line within this section. DSL: bit [5] in [0..31] b; C++: attr b { "b", width(5), range (0,31) }; Declare an unsigned variable that is 5-bits wide and has the valid values 1, 2, and 4. DSL: bit [5] in [1,2,4] c; C++: attr<bit> c { "c", width(5), range (1)(2)(4) }; Declare an unsigned variable that is 5-bits wide and has the valid values 0..10. DSL: bit [5] in[..10] b; // 0 <= b <= 10 C++: attr<bit> b {"b", width(5), range(lower,10)}; Declare an unsigned variable that is 5-bits wide and has the valid values 10..31. DSL: bit [5] in [10..] b; // 10 <= b <= 31 C++: attr<bit> b {"b", width(5), range(10, upper)}; =========================================================== examples with template 8.3.3 Examples =========================================================== DSL: config_modes_e in [MODE_A..MODE_C] mode_ac; C++: rand_attr<config_modes_e> mode_ac{"mode_ac",range<config_modes_e>(MODE_A,MODE_C)}; Declare an enum of type config_modes_e with values MODE_A or MODE_C. DSL: config_modes_e in [MODE_A, MODE_C] mode_ac; C++: rand_attr<config_modes_e> mode_ac{"mode_ac",range<config_modes_e>(MODE_A)(MODE_C)}; Declare an enum of type config_modes_e with values UNKNOWN, MODE_A, or MODE_B. DSL: config_modes_e in [..MODE_B] mode_ub; C++: rand_attr<config_modes_e> mode_ub{"mode_ub",range<config_modes_e>(lower,MODE_B)}; Declare an enum of type config_modes_e with values MODE_B, MODE_C, or MODE_D. DSL: config_modes_e in [MODE_B..] mode_bd; C++: rand_attr<config_modes_e> mode_bd{"mode_bd",range<config_modes_e>(MODE_B, upper)}; =========================================================== examples with template 8.4.3 Examples =========================================================== DSL: rand string in ["Hello", "Hallo", "Ni Hao"] hello_s; C++: rand_attr<std::string> hello_s{"hello_s",range<std::string>("Hello")("Hallo")("Ni Hao")}; =========================================================== Quote Link to comment Share on other sites More sharing options...
David Black Posted April 30, 2020 Report Share Posted April 30, 2020 Your question is inappropriate for this forum and organization. C++ is used by several of the standards here; however, the definition of C++ and its appropriate use should be redirected to the C++ standards organization elsewhere. This is also not a forum to debate the merits of syntax decisions made elsewhere unless you are proposing and contrasting the syntax with a fundamental language defined here. Quote Link to comment Share on other sites More sharing options...
Adnan Hamid Posted April 30, 2020 Report Share Posted April 30, 2020 Hi Dave, In the original poster's defense, this is a question regarding the PSS/C++ headers and not regarding the C++ standard. Quote Link to comment Share on other sites More sharing options...
Adnan Hamid Posted April 30, 2020 Report Share Posted April 30, 2020 Hi @junjieg, Thank you for the feedback. As your sharp eyes noted, this is an error in the 1.0a specification and will be corrected. `range()` should not be templated in the C++ examples. Quote Link to comment Share on other sites More sharing options...
David Black Posted May 1, 2020 Report Share Posted May 1, 2020 @junjiegI apologize for not understanding that your comment was referring to the header of the PSS standard. I will step aside. Quote Link to comment Share on other sites More sharing options...
jjguan Posted May 7, 2020 Report Share Posted May 7, 2020 On 4/30/2020 at 7:36 PM, David Black said: Hi David and Adnan, thanks for your time, very appreciate Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.