From: Jacob Lifshay Date: Mon, 5 Jun 2017 01:56:11 +0000 (-0700) Subject: change type naming style X-Git-Tag: gsoc-2017~109 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=371f4cc15f28954fcff3ca0f9db4e84084ab191a;p=kazan.git change type naming style --- diff --git a/src/demo/demo.cpp b/src/demo/demo.cpp index 65ebb11..601571f 100644 --- a/src/demo/demo.cpp +++ b/src/demo/demo.cpp @@ -33,22 +33,22 @@ namespace vulkan_cpu { namespace test { -util::optional> load_file(const char *fileName) +util::optional> load_file(const char *fileName) { - using spirv::word; + using spirv::Word; constexpr int eof = std::char_traits::eof(); std::ifstream is; is.open(fileName, std::ios::in | std::ios::binary); if(!is) return {}; constexpr std::size_t block_size = 0x1000; - std::vector> blocks; - std::array word_bytes{}; - static_assert(sizeof(word) == 4, ""); + std::vector> blocks; + std::array word_bytes{}; + static_assert(sizeof(Word) == 4, ""); static_assert(std::is_same::value, ""); - auto read_little_endian = [](const unsigned char *bytes) -> word + auto read_little_endian = [](const unsigned char *bytes) -> Word { - word retval = bytes[3]; + Word retval = bytes[3]; retval <<= 8; retval |= bytes[2]; retval <<= 8; @@ -57,9 +57,9 @@ util::optional> load_file(const char *fileName) retval |= bytes[0]; return retval; }; - auto read_big_endian = [](const unsigned char *bytes) -> word + auto read_big_endian = [](const unsigned char *bytes) -> Word { - word retval = bytes[0]; + Word retval = bytes[0]; retval <<= 8; retval |= bytes[1]; retval <<= 8; @@ -75,7 +75,7 @@ util::optional> load_file(const char *fileName) return {}; byte = v; } - word (*read_word_fn)(const unsigned char *) = nullptr; + Word (*read_word_fn)(const unsigned char *) = nullptr; if(read_little_endian(word_bytes.data()) == spirv::magic_number) read_word_fn = read_little_endian; else if(read_big_endian(word_bytes.data()) == spirv::magic_number) @@ -103,7 +103,7 @@ util::optional> load_file(const char *fileName) blocks.emplace_back(); } } - std::vector retval; + std::vector retval; retval.reserve(word_count); word_in_block_index = 0; for(std::size_t word_index = 0, block_index = 0; word_index < word_count; word_index++) @@ -118,7 +118,7 @@ util::optional> load_file(const char *fileName) return std::move(retval); } -void dump_words(const spirv::word *words, std::size_t word_count) +void dump_words(const spirv::Word *words, std::size_t word_count) { constexpr std::size_t max_words_per_line = 4; auto old_fill = std::cout.fill('0'); @@ -141,8 +141,8 @@ void dump_words(const spirv::word *words, std::size_t word_count) std::string chars = ""; auto write_line_ending = [&]() { - while(current_words_per_line < max_words_per_line) - { + while(current_words_per_line < max_words_per_line) + { std::cout << seperator; seperator = " "; std::cout.width(8); @@ -150,8 +150,8 @@ void dump_words(const spirv::word *words, std::size_t word_count) std::cout << ""; std::cout.fill('0'); current_words_per_line++; - } - std::cout << seperator << " |" << chars << "|\n"; + } + std::cout << seperator << " |" << chars << "|\n"; seperator = ""; wrote_line_ending = true; wrote_line_beginning = false; @@ -160,12 +160,12 @@ void dump_words(const spirv::word *words, std::size_t word_count) }; auto append_char = [&](unsigned ch) { - if(ch >= 0x20U && ch < 0x7FU) - chars += static_cast(ch); - else - chars += '.'; + if(ch >= 0x20U && ch < 0x7FU) + chars += static_cast(ch); + else + chars += '.'; }; - auto write_word = [&](spirv::word w) + auto write_word = [&](spirv::Word w) { std::cout << seperator; seperator = " "; @@ -193,7 +193,7 @@ void dump_words(const spirv::word *words, std::size_t word_count) std::cout.flags(old_flags); } -void dump_words(const std::vector &words) +void dump_words(const std::vector &words) { dump_words(words.data(), words.size()); } diff --git a/src/generate_spirv_parser/ast.h b/src/generate_spirv_parser/ast.h index 1779c8a..5d59a95 100644 --- a/src/generate_spirv_parser/ast.h +++ b/src/generate_spirv_parser/ast.h @@ -33,43 +33,43 @@ namespace generate_spirv_parser { namespace ast { -struct copyright +struct Copyright { - json::ast::array value; - copyright() : value() + json::ast::Array value; + Copyright() : value() { } - explicit copyright(json::ast::array value) noexcept : value(std::move(value)) + explicit Copyright(json::ast::Array value) noexcept : value(std::move(value)) { } }; -struct instructions +struct Instructions { #warning finish }; -struct operand_kinds +struct Operand_kinds { #warning finish }; -struct top_level +struct Top_level { - copyright copyright; + Copyright copyright; std::uint32_t magic_number; std::size_t major_version; std::size_t minor_version; std::size_t revision; - instructions instructions; - operand_kinds operand_kinds; - top_level(ast::copyright copyright, + Instructions instructions; + Operand_kinds operand_kinds; + Top_level(Copyright copyright, std::uint32_t magic_number, std::size_t major_version, std::size_t minor_version, std::size_t revision, - ast::instructions instructions, - ast::operand_kinds operand_kinds) + Instructions instructions, + Operand_kinds operand_kinds) : copyright(std::move(copyright)), magic_number(magic_number), major_version(major_version), diff --git a/src/generate_spirv_parser/generate_spirv_parser.cpp b/src/generate_spirv_parser/generate_spirv_parser.cpp index feaa3c8..eb48aee 100644 --- a/src/generate_spirv_parser/generate_spirv_parser.cpp +++ b/src/generate_spirv_parser/generate_spirv_parser.cpp @@ -42,18 +42,18 @@ int generate_spirv_parser_main(int argc, char **argv) } try { - auto source = file_name == "-" ? json::source::load_stdin() : - json::source::load_file(std::move(file_name)); + auto source = file_name == "-" ? json::Source::load_stdin() : + json::Source::load_file(std::move(file_name)); try { auto ast = parser::parse(json::parse(&source)); } - catch(json::parse_error &e) + catch(json::Parse_error &e) { std::cerr << "error: " << e.what() << std::endl; return 1; } - catch(parser::parse_error &e) + catch(parser::Parse_error &e) { std::cerr << "error: " << e.what() << std::endl; return 1; diff --git a/src/generate_spirv_parser/parser.cpp b/src/generate_spirv_parser/parser.cpp index 7596b92..ddaa34a 100644 --- a/src/generate_spirv_parser/parser.cpp +++ b/src/generate_spirv_parser/parser.cpp @@ -31,7 +31,7 @@ namespace generate_spirv_parser { namespace parser { -std::string path::to_string() const +std::string Path::to_string() const { std::ostringstream ss; ss << "root"; @@ -44,7 +44,7 @@ std::string path::to_string() const } else { - json::ast::string_value::write(ss, util::get(e)); + json::ast::String_value::write(ss, util::get(e)); } ss << ']'; } @@ -55,66 +55,66 @@ namespace { template Value get_value_or_throw_parse_error(util::optional value, - path_builder_base *path_builder, + Path_builder_base *path_builder, const char(&message)[N]) { if(value) return std::move(*value); - throw parse_error(path_builder ? path_builder->path() : path{}, message); + throw Parse_error(path_builder ? path_builder->path() : Path{}, message); } -ast::copyright parse_copyright(json::ast::value value, const path_builder_base *parent_path_builder) +ast::Copyright parse_copyright(json::ast::Value value, const Path_builder_base *parent_path_builder) { - if(json::ast::get_value_kind(value) != json::ast::value_kind::array) - throw parse_error(parent_path_builder->path(), "copyright is not an array"); + if(json::ast::get_value_kind(value) != json::ast::Value_kind::array) + throw Parse_error(parent_path_builder->path(), "copyright is not an array"); auto ©right_array = - static_cast(*util::get(value)); + static_cast(*util::get(value)); for(std::size_t index = 0; index < copyright_array.values.size(); index++) { - path_builder path_builder(&index, parent_path_builder); + Path_builder path_builder(&index, parent_path_builder); auto &element = copyright_array.values[index]; - if(json::ast::get_value_kind(element) != json::ast::value_kind::string) - throw parse_error(parent_path_builder->path(), + if(json::ast::get_value_kind(element) != json::ast::Value_kind::string) + throw Parse_error(parent_path_builder->path(), "copyright array's element is not a string"); } - return ast::copyright(std::move(copyright_array)); + return ast::Copyright(std::move(copyright_array)); } -ast::operand_kinds parse_operand_kinds(json::ast::value value, - const path_builder_base *parent_path_builder) +ast::Operand_kinds parse_operand_kinds(json::ast::Value value, + const Path_builder_base *parent_path_builder) { - if(json::ast::get_value_kind(value) != json::ast::value_kind::array) - throw parse_error(parent_path_builder->path(), "operand_kinds is not an array"); + if(json::ast::get_value_kind(value) != json::ast::Value_kind::array) + throw Parse_error(parent_path_builder->path(), "operand_kinds is not an array"); auto &operand_kinds_array = - static_cast(*util::get(value)); + static_cast(*util::get(value)); static_cast(operand_kinds_array); #warning finish - return ast::operand_kinds(); + return ast::Operand_kinds(); } -ast::instructions parse_instructions(json::ast::value value, - const path_builder_base *parent_path_builder) +ast::Instructions parse_instructions(json::ast::Value value, + const Path_builder_base *parent_path_builder) { - if(json::ast::get_value_kind(value) != json::ast::value_kind::array) - throw parse_error(parent_path_builder->path(), "instructions is not an array"); + if(json::ast::get_value_kind(value) != json::ast::Value_kind::array) + throw Parse_error(parent_path_builder->path(), "instructions is not an array"); auto &instructions_array = - static_cast(*util::get(value)); + static_cast(*util::get(value)); static_cast(instructions_array); #warning finish - return ast::instructions(); + return ast::Instructions(); } template -T parse_integer(const json::ast::value &value, - const path_builder_base *parent_path_builder, +T parse_integer(const json::ast::Value &value, + const Path_builder_base *parent_path_builder, const char *name) { - if(json::ast::get_value_kind(value) != json::ast::value_kind::number) - throw parse_error(parent_path_builder->path(), std::string(name) + " is not a number"); - auto number_value = util::get(value); + if(json::ast::get_value_kind(value) != json::ast::Value_kind::number) + throw Parse_error(parent_path_builder->path(), std::string(name) + " is not a number"); + auto number_value = util::get(value); T retval = number_value.value; if(retval != number_value.value) // not an exact value - throw parse_error(parent_path_builder->path(), std::string(name) + " is not an integer"); + throw Parse_error(parent_path_builder->path(), std::string(name) + " is not an integer"); return retval; } @@ -135,19 +135,19 @@ constexpr int get_digit_value(int ch, unsigned base) noexcept } template -T parse_hex_integer_string(const json::ast::value &value, - const path_builder_base *parent_path_builder, +T parse_hex_integer_string(const json::ast::Value &value, + const Path_builder_base *parent_path_builder, const char *name, std::size_t min_length, std::size_t max_length) { - if(json::ast::get_value_kind(value) != json::ast::value_kind::string) - throw parse_error(parent_path_builder->path(), std::string(name) + " is not a string"); - auto &string_value = util::get(value); + if(json::ast::get_value_kind(value) != json::ast::Value_kind::string) + throw Parse_error(parent_path_builder->path(), std::string(name) + " is not a string"); + auto &string_value = util::get(value); constexpr std::size_t hex_number_prefix_length = 2; // std::strlen("0x") if(string_value.value.size() < hex_number_prefix_length || string_value.value[0] != '0' || (string_value.value[1] != 'x' && string_value.value[1] != 'X')) - throw parse_error(parent_path_builder->path(), + throw Parse_error(parent_path_builder->path(), std::string(name) + " is not a valid hex number in a string"); constexpr T max_value = std::numeric_limits::max(); constexpr unsigned base = 0x10; @@ -159,42 +159,42 @@ T parse_hex_integer_string(const json::ast::value &value, char ch = string_value.value[i]; int digit = get_digit_value(ch, base); if(digit < 0) - throw parse_error(parent_path_builder->path(), + throw Parse_error(parent_path_builder->path(), std::string(name) + ": not a valid hex digit"); if(digit_count > max_length) - throw parse_error(parent_path_builder->path(), + throw Parse_error(parent_path_builder->path(), std::string(name) + " has too many digits"); if(retval > max_value / base || (retval = max_value / base && static_cast(digit) > max_value % base)) - throw parse_error(parent_path_builder->path(), std::string(name) + ": value too big"); + throw Parse_error(parent_path_builder->path(), std::string(name) + ": value too big"); retval *= base; retval += digit; } if(digit_count < min_length) - throw parse_error(parent_path_builder->path(), + throw Parse_error(parent_path_builder->path(), std::string(name) + " doesn't have enough digits"); return retval; } } -ast::top_level parse(json::ast::value &&top_level_value) +ast::Top_level parse(json::ast::Value &&top_level_value) { - if(json::ast::get_value_kind(top_level_value) != json::ast::value_kind::object) - throw parse_error({}, "top level value is not an object"); - auto &top_level_object = static_cast( - *util::get(top_level_value)); - util::optional copyright; + if(json::ast::get_value_kind(top_level_value) != json::ast::Value_kind::object) + throw Parse_error({}, "top level value is not an object"); + auto &top_level_object = static_cast( + *util::get(top_level_value)); + util::optional copyright; util::optional magic_number; util::optional major_version; util::optional minor_version; util::optional revision; - util::optional instructions; - util::optional operand_kinds; + util::optional instructions; + util::optional operand_kinds; for(auto &entry : top_level_object.values) { const auto &key = std::get<0>(entry); auto &entry_value = std::get<1>(entry); - path_builder path_builder(&key, nullptr); + Path_builder path_builder(&key, nullptr); if(key == "copyright") { copyright = parse_copyright(std::move(entry_value), &path_builder); @@ -226,10 +226,10 @@ ast::top_level parse(json::ast::value &&top_level_value) } else { - throw parse_error(path_builder.path(), "unknown key"); + throw Parse_error(path_builder.path(), "unknown key"); } } - auto retval = ast::top_level( + auto retval = ast::Top_level( get_value_or_throw_parse_error(std::move(copyright), nullptr, "missing copyright"), get_value_or_throw_parse_error(magic_number, nullptr, "missing magic_number"), get_value_or_throw_parse_error(major_version, nullptr, "missing major_version"), @@ -237,7 +237,7 @@ ast::top_level parse(json::ast::value &&top_level_value) get_value_or_throw_parse_error(revision, nullptr, "missing revision"), get_value_or_throw_parse_error(instructions, nullptr, "missing instructions"), get_value_or_throw_parse_error(operand_kinds, nullptr, "missing operand_kinds")); - throw parse_error({}, "not finished implementing"); + throw Parse_error({}, "not finished implementing"); } } } diff --git a/src/generate_spirv_parser/parser.h b/src/generate_spirv_parser/parser.h index 67e86bb..9ef3035 100644 --- a/src/generate_spirv_parser/parser.h +++ b/src/generate_spirv_parser/parser.h @@ -38,40 +38,40 @@ namespace generate_spirv_parser { namespace parser { -struct path +struct Path { typedef util::variant element; std::vector elements; - path() : elements() + Path() : elements() { } - path(std::vector elements) : elements(std::move(elements)) + Path(std::vector elements) : elements(std::move(elements)) { } - path(std::initializer_list elements) : elements(elements) + Path(std::initializer_list elements) : elements(elements) { } std::string to_string() const; }; -struct path_builder_base +struct Path_builder_base { - path_builder_base(const path_builder_base &) = delete; - path_builder_base &operator=(const path_builder_base &) = delete; - virtual ~path_builder_base() = default; - const path_builder_base *const parent; + Path_builder_base(const Path_builder_base &) = delete; + Path_builder_base &operator=(const Path_builder_base &) = delete; + virtual ~Path_builder_base() = default; + const Path_builder_base *const parent; const std::size_t element_count; - explicit path_builder_base(const path_builder_base *parent) noexcept + explicit Path_builder_base(const Path_builder_base *parent) noexcept : parent(parent), element_count(parent ? parent->element_count + 1 : 1) { } - virtual path::element get_element() const = 0; - path path() const + virtual Path::element get_element() const = 0; + Path path() const { - std::vector elements; + std::vector elements; elements.resize(element_count); - const path_builder_base *node = this; + const Path_builder_base *node = this; for(std::size_t i = 0, j = element_count - 1; i < element_count; i++, j--, node = node->parent) { @@ -84,31 +84,31 @@ struct path_builder_base }; template -struct path_builder final : public path_builder_base +struct Path_builder final : public Path_builder_base { const T *value; - path_builder(const T *value, const path_builder_base *parent) noexcept - : path_builder_base(parent), + Path_builder(const T *value, const Path_builder_base *parent) noexcept + : Path_builder_base(parent), value(value) { } - virtual path::element get_element() const override + virtual Path::element get_element() const override { return *value; } }; -class parse_error : public std::runtime_error +class Parse_error : public std::runtime_error { public: - path path; - parse_error(parser::path path, const std::string &message) + Path path; + Parse_error(parser::Path path, const std::string &message) : runtime_error("at " + path.to_string() + ": " + message), path(std::move(path)) { } }; -ast::top_level parse(json::ast::value &&top_level_value); +ast::Top_level parse(json::ast::Value &&top_level_value); } } } diff --git a/src/json/json.cpp b/src/json/json.cpp index 1dfad87..ad1582d 100644 --- a/src/json/json.cpp +++ b/src/json/json.cpp @@ -34,7 +34,7 @@ namespace vulkan_cpu { namespace json { -void write_state::write_indent(std::ostream &os) const +void Write_state::write_indent(std::ostream &os) const { for(std::size_t i = indent_level; i > 0; i--) os << options.indent_text; @@ -44,12 +44,12 @@ namespace ast { namespace soft_float = util::soft_float; -void null_value::write(std::ostream &os, write_state &state) const +void Null_value::write(std::ostream &os, Write_state &state) const { os << "null"; } -void boolean_value::write(std::ostream &os, write_state &state) const +void Boolean_value::write(std::ostream &os, Write_state &state) const { os << (value ? "true" : "false"); } @@ -66,7 +66,7 @@ constexpr char get_digit_char(unsigned digit, bool uppercase) noexcept } } -void string_value::write(std::ostream &os, const std::string &value, write_state &state) +void String_value::write(std::ostream &os, const std::string &value, Write_state &state) { os << '\"'; for(unsigned char ch : value) @@ -170,7 +170,7 @@ void write_unsigned_integer(Write_Char write_char, std::uint64_t value, unsigned base) noexcept(noexcept(write_char('0'))) { - assert(base >= number_value::min_base && base <= number_value::max_base); + assert(base >= Number_value::min_base && base <= Number_value::max_base); char buffer[max_integer_buffer_size]{}; std::size_t buffer_used = 0; do @@ -209,7 +209,7 @@ void write_number(Write_Char write_char, // code modified from // https://github.com/programmerjake/javascript-tasklets/blob/master/javascript_tasklets/value.cpp // based on the ECMAScript ToString algorithm for numbers - assert(base >= number_value::min_base && base <= number_value::max_base); + assert(base >= Number_value::min_base && base <= Number_value::max_base); const char exponent_char = base == 10 ? 'e' : base == 16 ? 'h' : base == 8 ? 'o' : 'E'; soft_float::ExtendedFloat value(valueIn), base_f(static_cast(base)); auto inv_base_f = soft_float::ExtendedFloat::One() / base_f; @@ -344,7 +344,7 @@ void write_number(Write_Char write_char, } } -std::string number_value::append_double_to_string(double value, std::string buffer, unsigned base) +std::string Number_value::append_double_to_string(double value, std::string buffer, unsigned base) { write_number( [&](char ch) @@ -356,7 +356,7 @@ std::string number_value::append_double_to_string(double value, std::string buff return buffer; } -std::size_t number_value::double_to_buffer(double value, +std::size_t Number_value::double_to_buffer(double value, char *output_buffer, std::size_t output_buffer_size, bool require_null_terminator, @@ -381,7 +381,7 @@ std::size_t number_value::double_to_buffer(double value, return used_buffer_size; // report used buffer excluding the null terminator } -std::string number_value::append_unsigned_integer_to_string(std::uint64_t value, +std::string Number_value::append_unsigned_integer_to_string(std::uint64_t value, std::string buffer, unsigned base) { @@ -395,7 +395,7 @@ std::string number_value::append_unsigned_integer_to_string(std::uint64_t value, return buffer; } -std::size_t number_value::unsigned_integer_to_buffer(std::uint64_t value, +std::size_t Number_value::unsigned_integer_to_buffer(std::uint64_t value, char *output_buffer, std::size_t output_buffer_size, bool require_null_terminator, @@ -420,7 +420,7 @@ std::size_t number_value::unsigned_integer_to_buffer(std::uint64_t value, return used_buffer_size; // report used buffer excluding the null terminator } -std::string number_value::append_signed_integer_to_string(std::int64_t value, +std::string Number_value::append_signed_integer_to_string(std::int64_t value, std::string buffer, unsigned base) { @@ -434,7 +434,7 @@ std::string number_value::append_signed_integer_to_string(std::int64_t value, return buffer; } -std::size_t number_value::signed_integer_to_buffer(std::int64_t value, +std::size_t Number_value::signed_integer_to_buffer(std::int64_t value, char *output_buffer, std::size_t output_buffer_size, bool require_null_terminator, @@ -459,7 +459,7 @@ std::size_t number_value::signed_integer_to_buffer(std::int64_t value, return used_buffer_size; // report used buffer excluding the null terminator } -void number_value::write(std::ostream &os, write_state &state, unsigned base) const +void Number_value::write(std::ostream &os, Write_state &state, unsigned base) const { write_number( [&](char ch) @@ -470,17 +470,17 @@ void number_value::write(std::ostream &os, write_state &state, unsigned base) co base); } -void object::write(std::ostream &os, write_state &state) const +void Object::write(std::ostream &os, Write_state &state) const { os << '{'; if(!values.empty()) { - write_state::push_indent push_indent(state); + Write_state::Push_indent push_indent(state); auto seperator = ""; - auto write_entry = [&](const std::pair &entry) + auto write_entry = [&](const std::pair &entry) { const std::string &key = std::get<0>(entry); - const value &value = std::get<1>(entry); + const Value &value = std::get<1>(entry); os << seperator; seperator = ","; if(state.options.composite_value_elements_on_seperate_lines) @@ -488,7 +488,7 @@ void object::write(std::ostream &os, write_state &state) const os << '\n'; state.write_indent(os); } - string_value::write(os, key, state); + String_value::write(os, key, state); os << ':'; json::write(os, value, state); }; @@ -522,14 +522,14 @@ void object::write(std::ostream &os, write_state &state) const os << '}'; } -void array::write(std::ostream &os, write_state &state) const +void Array::write(std::ostream &os, Write_state &state) const { os << '['; if(!values.empty()) { - write_state::push_indent push_indent(state); + Write_state::Push_indent push_indent(state); auto seperator = ""; - for(const value &v : values) + for(const Value &v : values) { os << seperator; seperator = ","; diff --git a/src/json/json.h b/src/json/json.h index 8ac3070..d32acdc 100644 --- a/src/json/json.h +++ b/src/json/json.h @@ -39,15 +39,15 @@ namespace vulkan_cpu { namespace json { -struct write_options +struct Write_options { bool composite_value_elements_on_seperate_lines = false; bool sort_object_values = false; std::string indent_text = ""; - write_options() + Write_options() { } - write_options(bool composite_value_elements_on_seperate_lines, + Write_options(bool composite_value_elements_on_seperate_lines, bool sort_object_values, std::string indent_text) noexcept : composite_value_elements_on_seperate_lines(composite_value_elements_on_seperate_lines), @@ -55,31 +55,31 @@ struct write_options indent_text(std::move(indent_text)) { } - static write_options defaults() + static Write_options defaults() { return {}; } - static write_options pretty(std::string indent_text = " ") + static Write_options pretty(std::string indent_text = " ") { - return write_options(true, true, std::move(indent_text)); + return Write_options(true, true, std::move(indent_text)); } }; -struct write_state +struct Write_state { - write_options options; + Write_options options; std::size_t indent_level = 0; - class push_indent final + class Push_indent final { - push_indent(const push_indent &) = delete; - push_indent &operator=(const push_indent &) = delete; + Push_indent(const Push_indent &) = delete; + Push_indent &operator=(const Push_indent &) = delete; private: - write_state &state; + Write_state &state; bool finished = false; public: - push_indent(write_state &state) : state(state) + Push_indent(Write_state &state) : state(state) { state.indent_level++; } @@ -89,13 +89,13 @@ struct write_state state.indent_level--; finished = true; } - ~push_indent() + ~Push_indent() { if(!finished) state.indent_level--; } }; - write_state(write_options options) : options(std::move(options)) + Write_state(Write_options options) : options(std::move(options)) { } void write_indent(std::ostream &os) const; @@ -103,7 +103,7 @@ struct write_state namespace ast { -enum class value_kind +enum class Value_kind { null, boolean, @@ -113,96 +113,96 @@ enum class value_kind array }; -struct null_value final +struct Null_value final { - constexpr null_value() noexcept = default; - constexpr null_value(std::nullptr_t) noexcept + constexpr Null_value() noexcept = default; + constexpr Null_value(std::nullptr_t) noexcept { } - void write(std::ostream &os, write_state &state) const; - null_value duplicate() const noexcept + void write(std::ostream &os, Write_state &state) const; + Null_value duplicate() const noexcept { return {}; } - const null_value *operator->() const noexcept + const Null_value *operator->() const noexcept { return this; } - const null_value &operator*() const noexcept + const Null_value &operator*() const noexcept { return *this; } - constexpr value_kind get_value_kind() const noexcept + constexpr Value_kind get_value_kind() const noexcept { - return value_kind::null; + return Value_kind::null; } }; -struct boolean_value final +struct Boolean_value final { bool value; template ::value>::type> - constexpr boolean_value(T value) noexcept : value(value) + constexpr Boolean_value(T value) noexcept : value(value) { } - void write(std::ostream &os, write_state &state) const; - boolean_value duplicate() const noexcept + void write(std::ostream &os, Write_state &state) const; + Boolean_value duplicate() const noexcept { return *this; } - const boolean_value *operator->() const noexcept + const Boolean_value *operator->() const noexcept { return this; } - const boolean_value &operator*() const noexcept + const Boolean_value &operator*() const noexcept { return *this; } - constexpr value_kind get_value_kind() const noexcept + constexpr Value_kind get_value_kind() const noexcept { - return value_kind::boolean; + return Value_kind::boolean; } }; -struct string_value final +struct String_value final { std::string value; template < typename T, typename = typename std::enable_if::value && std::is_convertible::value>::type> - string_value(T value) noexcept : value(std::move(value)) + String_value(T value) noexcept : value(std::move(value)) { } - static void write(std::ostream &os, const std::string &value, write_state &state); + static void write(std::ostream &os, const std::string &value, Write_state &state); static void write(std::ostream &os, const std::string &value) { - write_state state(write_options::defaults()); + Write_state state(Write_options::defaults()); write(os, value, state); } - void write(std::ostream &os, write_state &state) const + void write(std::ostream &os, Write_state &state) const { write(os, value, state); } - string_value duplicate() const noexcept + String_value duplicate() const noexcept { return *this; } - const string_value *operator->() const noexcept + const String_value *operator->() const noexcept { return this; } - const string_value &operator*() const noexcept + const String_value &operator*() const noexcept { return *this; } - constexpr value_kind get_value_kind() const noexcept + constexpr Value_kind get_value_kind() const noexcept { - return value_kind::string; + return Value_kind::string; } }; -struct number_value final +struct Number_value final { double value; static_assert(std::numeric_limits::is_iec559 && std::numeric_limits::radix == 2, @@ -210,7 +210,7 @@ struct number_value final template ::value && !std::is_same::value>::type> - number_value(T value) noexcept : value(value) + Number_value(T value) noexcept : value(value) { } explicit operator std::string() const @@ -281,138 +281,138 @@ struct number_value final std::size_t output_buffer_size, bool require_null_terminator = true, unsigned base = default_base) noexcept; - void write(std::ostream &os, write_state &state, unsigned base = default_base) const; - number_value duplicate() const noexcept + void write(std::ostream &os, Write_state &state, unsigned base = default_base) const; + Number_value duplicate() const noexcept { return *this; } - const number_value *operator->() const noexcept + const Number_value *operator->() const noexcept { return this; } - const number_value &operator*() const noexcept + const Number_value &operator*() const noexcept { return *this; } - constexpr value_kind get_value_kind() const noexcept + constexpr Value_kind get_value_kind() const noexcept { - return value_kind::number; + return Value_kind::number; } }; -struct composite_value; +struct Composite_value; -class composite_value_pointer +class Composite_value_pointer { private: - std::shared_ptr value; + std::shared_ptr value; public: - constexpr composite_value_pointer() noexcept = default; + constexpr Composite_value_pointer() noexcept = default; template ::value>::type> - composite_value_pointer(std::shared_ptr value) noexcept : value(std::move(value)) + typename = typename std::enable_if::value>::type> + Composite_value_pointer(std::shared_ptr value) noexcept : value(std::move(value)) { } - composite_value *operator->() const noexcept + Composite_value *operator->() const noexcept { return value.operator->(); } - composite_value &operator*() const noexcept + Composite_value &operator*() const noexcept { return *value; } - const std::shared_ptr &get() const &noexcept + const std::shared_ptr &get() const &noexcept { return value; } - std::shared_ptr get() && noexcept + std::shared_ptr get() && noexcept { - std::shared_ptr retval = nullptr; + std::shared_ptr retval = nullptr; retval.swap(value); return retval; } }; typedef util:: - variant value; + variant Value; -struct composite_value +struct Composite_value { - composite_value() = default; - virtual ~composite_value() = default; - virtual void write(std::ostream &os, write_state &state) const = 0; - virtual composite_value_pointer duplicate() const = 0; - operator value() const + Composite_value() = default; + virtual ~Composite_value() = default; + virtual void write(std::ostream &os, Write_state &state) const = 0; + virtual Composite_value_pointer duplicate() const = 0; + operator Value() const { return duplicate(); } - virtual value_kind get_value_kind() const noexcept = 0; + virtual Value_kind get_value_kind() const noexcept = 0; }; -inline value duplicate(const value &v) +inline Value duplicate(const Value &v) { return util::visit( - [](const auto &v) -> value + [](const auto &v) -> Value { return v->duplicate(); }, v); } -struct object final : public composite_value +struct Object final : public Composite_value { - std::unordered_map values; - object() : values() + std::unordered_map values; + Object() : values() { } - object(std::unordered_map values) noexcept : values(std::move(values)) + Object(std::unordered_map values) noexcept : values(std::move(values)) { } - virtual void write(std::ostream &os, write_state &state) const override; - virtual composite_value_pointer duplicate() const override + virtual void write(std::ostream &os, Write_state &state) const override; + virtual Composite_value_pointer duplicate() const override { - std::unordered_map new_values; + std::unordered_map new_values; for(auto &entry : values) { new_values.emplace(std::get<0>(entry), ast::duplicate(std::get<1>(entry))); } - return std::make_shared(std::move(new_values)); + return std::make_shared(std::move(new_values)); } - value_kind get_value_kind() const noexcept override + Value_kind get_value_kind() const noexcept override { - return value_kind::object; + return Value_kind::object; } }; -struct array final : public composite_value +struct Array final : public Composite_value { - std::vector values; - array() : values() + std::vector values; + Array() : values() { } - array(std::vector values) noexcept : values(std::move(values)) + Array(std::vector values) noexcept : values(std::move(values)) { } - virtual void write(std::ostream &os, write_state &state) const override; - virtual composite_value_pointer duplicate() const override + virtual void write(std::ostream &os, Write_state &state) const override; + virtual Composite_value_pointer duplicate() const override { - std::vector new_values; + std::vector new_values; new_values.reserve(values.size()); for(auto &value : values) new_values.emplace_back(ast::duplicate(value)); - return std::make_shared(std::move(new_values)); + return std::make_shared(std::move(new_values)); } - value_kind get_value_kind() const noexcept override + Value_kind get_value_kind() const noexcept override { - return value_kind::array; + return Value_kind::array; } }; -inline value_kind get_value_kind(const value &v) noexcept +inline Value_kind get_value_kind(const Value &v) noexcept { return util::visit( - [&](const auto &v) -> value_kind + [&](const auto &v) -> Value_kind { return v->get_value_kind(); }, @@ -420,7 +420,7 @@ inline value_kind get_value_kind(const value &v) noexcept } } -inline void write(std::ostream &os, const ast::value &v, write_state &state) +inline void write(std::ostream &os, const ast::Value &v, Write_state &state) { util::visit( [&](const auto &v) -> void @@ -430,9 +430,9 @@ inline void write(std::ostream &os, const ast::value &v, write_state &state) v); } -inline void write(std::ostream &os, const ast::value &v, write_options options = {}) +inline void write(std::ostream &os, const ast::Value &v, Write_options options = {}) { - write_state state(std::move(options)); + Write_state state(std::move(options)); write(os, v, state); } } diff --git a/src/json/parser.cpp b/src/json/parser.cpp index 56a25de..36ed166 100644 --- a/src/json/parser.cpp +++ b/src/json/parser.cpp @@ -68,7 +68,7 @@ void find_line_start_indexes_helper(Add_Index &&add_index, } } -std::vector source::find_line_start_indexes(const char *contents, +std::vector Source::find_line_start_indexes(const char *contents, std::size_t contents_size) { std::size_t retval_size = 0; @@ -91,7 +91,7 @@ std::vector source::find_line_start_indexes(const char *contents, return retval; } -source source::load_file(std::string file_name) +Source Source::load_file(std::string file_name) { // TODO: add code to use mmap std::ifstream is; @@ -109,10 +109,10 @@ source source::load_file(std::string file_name) std::size_t contents_size = buffer.size(); auto buffer_ptr = std::make_shared>(std::move(buffer)); std::shared_ptr contents(buffer_ptr, buffer_ptr->data()); - return source(std::move(file_name), std::move(contents), contents_size); + return Source(std::move(file_name), std::move(contents), contents_size); } -source source::load_stdin() +Source Source::load_stdin() { auto &is = std::cin; is.clear(); @@ -139,16 +139,16 @@ source source::load_stdin() std::size_t contents_size = buffer.size(); auto buffer_ptr = std::make_shared>(std::move(buffer)); std::shared_ptr contents(buffer_ptr, buffer_ptr->data()); - return source("stdin", std::move(contents), contents_size); + return Source("stdin", std::move(contents), contents_size); } -std::ostream &operator<<(std::ostream &os, const source::line_and_column &v) +std::ostream &operator<<(std::ostream &os, const Source::Line_and_column &v) { os << v.to_string(); return os; } -source::line_and_index source::get_line_and_start_index(std::size_t char_index) const noexcept +Source::Line_and_index Source::get_line_and_start_index(std::size_t char_index) const noexcept { std::size_t line = 1 + line_start_indexes.size() @@ -156,7 +156,7 @@ source::line_and_index source::get_line_and_start_index(std::size_t char_index) line_start_indexes.rend(), char_index, std::greater())); - return line_and_index(line, line <= 1 ? 0 : line_start_indexes[line - 2]); + return Line_and_index(line, line <= 1 ? 0 : line_start_indexes[line - 2]); } namespace @@ -168,7 +168,7 @@ constexpr std::size_t get_column_after_tab(std::size_t column, std::size_t tab_s } } -source::line_and_column source::get_line_and_column(std::size_t char_index, +Source::Line_and_column Source::get_line_and_column(std::size_t char_index, std::size_t tab_size) const noexcept { auto line_and_start_index = get_line_and_start_index(char_index); @@ -181,10 +181,10 @@ source::line_and_column source::get_line_and_column(std::size_t char_index, else column++; } - return line_and_column(line_and_start_index.line, column); + return Line_and_column(line_and_start_index.line, column); } -std::ostream &operator<<(std::ostream &os, const location &v) +std::ostream &operator<<(std::ostream &os, const Location &v) { os << v.to_string(); return os; @@ -192,7 +192,7 @@ std::ostream &operator<<(std::ostream &os, const location &v) namespace { -enum class token_type +enum class Token_type { eof, l_bracket, @@ -208,18 +208,18 @@ enum class token_type number, }; -class tokenizer final +class Tokenizer final { private: std::size_t input_char_index; static constexpr int eof = std::char_traits::eof(); public: - const source *const source; - const parse_options options; - location token_location; - ast::value token_value; - token_type token_type; + const Source *const source; + const Parse_options options; + Location token_location; + ast::Value token_value; + Token_type token_type; private: int peekc() const noexcept @@ -284,7 +284,7 @@ private: int digit_char = peekc(); int digit_value = get_digit_value(digit_char, 0x10); if(digit_value < 0) - throw parse_error(location(source, input_char_index), "missing hex digit"); + throw Parse_error(Location(source, input_char_index), "missing hex digit"); getc(); retval <<= 4; retval |= digit_value; @@ -319,12 +319,12 @@ private: } public: - tokenizer(const json::source *source, parse_options options) + Tokenizer(const json::Source *source, Parse_options options) : input_char_index(0), source(source), options(options), token_location(), token_value() { next(); } - ast::value get() + ast::Value get() { auto retval = token_value; next(); @@ -334,7 +334,7 @@ public: { while(is_whitespace(peekc())) getc(); - token_location = location(source, input_char_index); + token_location = Location(source, input_char_index); token_value = nullptr; bool got_minus = false, got_plus = false; if(peekc() == '-') @@ -361,19 +361,19 @@ public: if(match_buffer_with_string(name, name_size, "null")) { token_value = nullptr; - token_type = json::token_type::null_literal; + token_type = json::Token_type::null_literal; return; } if(match_buffer_with_string(name, name_size, "false")) { token_value = false; - token_type = json::token_type::false_literal; + token_type = json::Token_type::false_literal; return; } if(match_buffer_with_string(name, name_size, "true")) { token_value = true; - token_type = json::token_type::true_literal; + token_type = json::Token_type::true_literal; return; } } @@ -384,7 +384,7 @@ public: || match_buffer_with_string(name, name_size, "NAN")) { token_value = std::numeric_limits::quiet_NaN(); - token_type = json::token_type::number; + token_type = json::Token_type::number; return; } if(match_buffer_with_string(name, name_size, "Infinity") @@ -395,11 +395,11 @@ public: { token_value = got_minus ? -std::numeric_limits::infinity() : std::numeric_limits::infinity(); - token_type = json::token_type::number; + token_type = json::Token_type::number; return; } } - throw parse_error(token_location, + throw Parse_error(token_location, (got_minus || got_plus ? "invalid number: " : "invalid identifier: ") + std::string(name, name_size)); } @@ -415,7 +415,7 @@ public: getc(); got_any_digit = true; if(is_digit(peekc())) - throw parse_error(location(source, input_char_index), + throw Parse_error(Location(source, input_char_index), "extra leading zero not allowed in numbers"); } else @@ -443,7 +443,7 @@ public: } } if(!got_any_digit) - throw parse_error(location(source, input_char_index), "missing digit"); + throw Parse_error(Location(source, input_char_index), "missing digit"); std::int64_t exponent = 0; if(peekc() == 'e' || peekc() == 'E') { @@ -459,7 +459,7 @@ public: getc(); } if(!is_digit(peekc())) - throw parse_error(location(source, input_char_index), "missing digit"); + throw Parse_error(Location(source, input_char_index), "missing digit"); while(is_digit(peekc())) { exponent *= 10; @@ -472,7 +472,7 @@ public: auto value = mantissa * pow(util::soft_float::ExtendedFloat(static_cast(10)), exponent); - token_type = json::token_type::number; + token_type = json::Token_type::number; token_value = static_cast(value); return; } @@ -483,7 +483,7 @@ public: while(true) { if(peekc() == eof || is_control_character(peekc())) - throw parse_error(token_location, "string missing closing quote"); + throw Parse_error(token_location, "string missing closing quote"); if(peekc() == quote) { getc(); @@ -491,7 +491,7 @@ public: } if(peekc() == '\\') { - auto escape_location = location(source, input_char_index); + auto escape_location = Location(source, input_char_index); getc(); switch(peekc()) { @@ -526,7 +526,7 @@ public: std::uint32_t ch = parse_4_hex_digits(); if(ch >= 0xD800U && ch < 0xDC00U && peekc() == '\\') { - escape_location = location(source, input_char_index); + escape_location = Location(source, input_char_index); getc(); if(peekc() == 'u') { @@ -556,7 +556,7 @@ public: value += getc(); break; } - throw parse_error(escape_location, "invalid escape sequence"); + throw Parse_error(escape_location, "invalid escape sequence"); } } else @@ -564,68 +564,68 @@ public: value += getc(); } } - token_type = json::token_type::string; + token_type = json::Token_type::string; token_value = std::move(value); return; } switch(peekc()) { case eof: - token_type = json::token_type::eof; + token_type = json::Token_type::eof; token_value = nullptr; return; case '[': getc(); - token_type = json::token_type::l_bracket; + token_type = json::Token_type::l_bracket; token_value = nullptr; return; case ']': getc(); - token_type = json::token_type::r_bracket; + token_type = json::Token_type::r_bracket; token_value = nullptr; return; case '{': getc(); - token_type = json::token_type::l_brace; + token_type = json::Token_type::l_brace; token_value = nullptr; return; case '}': getc(); - token_type = json::token_type::r_brace; + token_type = json::Token_type::r_brace; token_value = nullptr; return; case ':': getc(); - token_type = json::token_type::colon; + token_type = json::Token_type::colon; token_value = nullptr; return; case ',': getc(); - token_type = json::token_type::comma; + token_type = json::Token_type::comma; token_value = nullptr; return; } - throw parse_error(token_location, "invalid character"); + throw Parse_error(token_location, "invalid character"); } }; -ast::value parse_value(tokenizer &tokenizer) +ast::Value parse_value(Tokenizer &tokenizer) { switch(tokenizer.token_type) { - case token_type::eof: - throw parse_error(tokenizer.token_location, "missing value"); - case token_type::number: - case token_type::string: - case token_type::true_literal: - case token_type::false_literal: - case token_type::null_literal: + case Token_type::eof: + throw Parse_error(tokenizer.token_location, "missing value"); + case Token_type::number: + case Token_type::string: + case Token_type::true_literal: + case Token_type::false_literal: + case Token_type::null_literal: return tokenizer.get(); - case token_type::l_bracket: + case Token_type::l_bracket: { - std::vector values; + std::vector values; tokenizer.next(); - if(tokenizer.token_type == token_type::r_bracket) + if(tokenizer.token_type == Token_type::r_bracket) { tokenizer.next(); } @@ -634,26 +634,26 @@ ast::value parse_value(tokenizer &tokenizer) while(true) { values.push_back(parse_value(tokenizer)); - if(tokenizer.token_type == token_type::comma) + if(tokenizer.token_type == Token_type::comma) { tokenizer.next(); continue; } - if(tokenizer.token_type == token_type::r_bracket) + if(tokenizer.token_type == Token_type::r_bracket) { tokenizer.next(); break; } - throw parse_error(tokenizer.token_location, "missing , or ]"); + throw Parse_error(tokenizer.token_location, "missing , or ]"); } } - return ast::array(std::move(values)); + return ast::Array(std::move(values)); } - case token_type::l_brace: + case Token_type::l_brace: { - std::unordered_map values; + std::unordered_map values; tokenizer.next(); - if(tokenizer.token_type == token_type::r_brace) + if(tokenizer.token_type == Token_type::r_brace) { tokenizer.next(); } @@ -661,41 +661,41 @@ ast::value parse_value(tokenizer &tokenizer) { while(true) { - if(tokenizer.token_type != token_type::string) - throw parse_error(tokenizer.token_location, "missing string"); - auto string_value = std::move(util::get(tokenizer.get()).value); - if(tokenizer.token_type != token_type::colon) - throw parse_error(tokenizer.token_location, "missing ':'"); + if(tokenizer.token_type != Token_type::string) + throw Parse_error(tokenizer.token_location, "missing string"); + auto string_value = std::move(util::get(tokenizer.get()).value); + if(tokenizer.token_type != Token_type::colon) + throw Parse_error(tokenizer.token_location, "missing ':'"); tokenizer.next(); values.emplace(std::move(string_value), parse_value(tokenizer)); - if(tokenizer.token_type == token_type::comma) + if(tokenizer.token_type == Token_type::comma) { tokenizer.next(); continue; } - if(tokenizer.token_type == token_type::r_brace) + if(tokenizer.token_type == Token_type::r_brace) { tokenizer.next(); break; } - throw parse_error(tokenizer.token_location, "missing ',' or '}'"); + throw Parse_error(tokenizer.token_location, "missing ',' or '}'"); } } - return ast::object(std::move(values)); + return ast::Object(std::move(values)); } default: break; } - throw parse_error(tokenizer.token_location, "token not allowed here"); + throw Parse_error(tokenizer.token_location, "token not allowed here"); } } -ast::value parse(const source *source, parse_options options) +ast::Value parse(const Source *source, Parse_options options) { - tokenizer tokenizer(source, options); + Tokenizer tokenizer(source, options); auto retval = parse_value(tokenizer); - if(tokenizer.token_type != token_type::eof) - throw parse_error(tokenizer.token_location, "unexpected token"); + if(tokenizer.token_type != Token_type::eof) + throw Parse_error(tokenizer.token_location, "unexpected token"); return retval; } } diff --git a/src/json/parser.h b/src/json/parser.h index 747a404..ddc3ae5 100644 --- a/src/json/parser.h +++ b/src/json/parser.h @@ -36,7 +36,7 @@ namespace vulkan_cpu { namespace json { -struct source +struct Source { std::string file_name; std::shared_ptr contents; // use a shared_ptr so you can use mmap-ed memory @@ -45,20 +45,20 @@ struct source std::vector line_start_indexes; static std::vector find_line_start_indexes(const char *contents, std::size_t contents_size); - source(source &&) = default; - source(const source &) = delete; - source &operator=(source &&) = default; - source &operator=(const source &) = delete; - source() : file_name(), contents(), contents_size(0), line_start_indexes() + Source(Source &&) = default; + Source(const Source &) = delete; + Source &operator=(Source &&) = default; + Source &operator=(const Source &) = delete; + Source() : file_name(), contents(), contents_size(0), line_start_indexes() { } - explicit source(std::string file_name) noexcept : file_name(std::move(file_name)), + explicit Source(std::string file_name) noexcept : file_name(std::move(file_name)), contents(), contents_size(0), line_start_indexes() { } - source(std::string file_name, + Source(std::string file_name, std::shared_ptr contents, std::size_t contents_size) noexcept : file_name(std::move(file_name)), @@ -67,7 +67,7 @@ struct source line_start_indexes(find_line_start_indexes(this->contents.get(), contents_size)) { } - source(std::string file_name, std::string contents_in) + Source(std::string file_name, std::string contents_in) : file_name(file_name), contents(), contents_size(contents_in.size()), @@ -76,7 +76,7 @@ struct source auto str = std::make_shared(std::move(contents_in)); contents = std::shared_ptr(str, str->data()); } - source(std::string file_name, std::vector contents_in) + Source(std::string file_name, std::vector contents_in) : file_name(file_name), contents(), contents_size(contents_in.size()), @@ -85,7 +85,7 @@ struct source auto str = std::make_shared>(std::move(contents_in)); contents = std::shared_ptr(str, str->data()); } - source(std::string file_name, std::vector contents_in) + Source(std::string file_name, std::vector contents_in) : file_name(file_name), contents(), contents_size(contents_in.size()), @@ -99,37 +99,37 @@ struct source { return contents != nullptr; } - static source load_file(std::string file_name); - static source load_stdin(); - struct line_and_index + static Source load_file(std::string file_name); + static Source load_stdin(); + struct Line_and_index { std::size_t line; std::size_t index; - constexpr line_and_index() noexcept : line(), index() + constexpr Line_and_index() noexcept : line(), index() { } - constexpr line_and_index(std::size_t line, std::size_t index) noexcept : line(line), + constexpr Line_and_index(std::size_t line, std::size_t index) noexcept : line(line), index(index) { } }; - struct line_and_column + struct Line_and_column { std::size_t line; std::size_t column; - constexpr line_and_column() noexcept : line(), column() + constexpr Line_and_column() noexcept : line(), column() { } - constexpr line_and_column(std::size_t line, std::size_t column) noexcept : line(line), + constexpr Line_and_column(std::size_t line, std::size_t column) noexcept : line(line), column(column) { } std::string append_to_string(std::string buffer) const { - buffer = ast::number_value::append_unsigned_integer_to_string(line, std::move(buffer)); + buffer = ast::Number_value::append_unsigned_integer_to_string(line, std::move(buffer)); buffer += ':'; buffer = - ast::number_value::append_unsigned_integer_to_string(column, std::move(buffer)); + ast::Number_value::append_unsigned_integer_to_string(column, std::move(buffer)); return buffer; } std::string to_string(std::string buffer = {}) const @@ -137,47 +137,47 @@ struct source buffer.clear(); return append_to_string(std::move(buffer)); } - friend std::ostream &operator<<(std::ostream &os, const line_and_column &v); + friend std::ostream &operator<<(std::ostream &os, const Line_and_column &v); }; static constexpr std::size_t default_tab_size = 8; - line_and_index get_line_and_start_index(std::size_t char_index) const noexcept; - line_and_column get_line_and_column(std::size_t char_index, + Line_and_index get_line_and_start_index(std::size_t char_index) const noexcept; + Line_and_column get_line_and_column(std::size_t char_index, std::size_t tab_size = default_tab_size) const noexcept; }; -struct location +struct Location { - const source *source; + const Source *source; std::size_t char_index; - constexpr location() noexcept : source(nullptr), char_index(0) + constexpr Location() noexcept : source(nullptr), char_index(0) { } - constexpr location(const json::source *source, std::size_t char_index) noexcept + constexpr Location(const json::Source *source, std::size_t char_index) noexcept : source(source), char_index(char_index) { } - json::source::line_and_index get_line_and_start_index() const noexcept + json::Source::Line_and_index get_line_and_start_index() const noexcept { if(!source) return {}; return source->get_line_and_start_index(char_index); } - json::source::line_and_column get_line_and_column( - std::size_t tab_size = json::source::default_tab_size) const noexcept + json::Source::Line_and_column get_line_and_column( + std::size_t tab_size = json::Source::default_tab_size) const noexcept { if(!source) return {}; return source->get_line_and_column(char_index, tab_size); } std::string to_string(std::string buffer = {}, - std::size_t tab_size = json::source::default_tab_size) const + std::size_t tab_size = json::Source::default_tab_size) const { buffer.clear(); return append_to_string(std::move(buffer)); } std::string append_to_string(std::string buffer, - std::size_t tab_size = json::source::default_tab_size) const + std::size_t tab_size = json::Source::default_tab_size) const { if(!source || source->file_name.empty()) buffer += ""; @@ -187,36 +187,36 @@ struct location buffer = get_line_and_column(tab_size).append_to_string(std::move(buffer)); return buffer; } - friend std::ostream &operator<<(std::ostream &os, const location &v); + friend std::ostream &operator<<(std::ostream &os, const Location &v); }; -class parse_error : public std::runtime_error +class Parse_error : public std::runtime_error { public: - location location; - parse_error(json::location location, const std::string &message) + Location location; + Parse_error(json::Location location, const std::string &message) : runtime_error(location.to_string() + ": " + message) { } - parse_error(json::location location, const char *message) + Parse_error(json::Location location, const char *message) : runtime_error(location.to_string() + ": " + message) { } }; -struct parse_options +struct Parse_options { bool allow_infinity_and_nan; bool allow_explicit_plus_sign_in_mantissa; bool allow_single_quote_strings; bool allow_number_to_start_with_dot; - constexpr parse_options() noexcept : allow_infinity_and_nan(false), + constexpr Parse_options() noexcept : allow_infinity_and_nan(false), allow_explicit_plus_sign_in_mantissa(false), allow_single_quote_strings(false), allow_number_to_start_with_dot(false) { } - constexpr parse_options(bool allow_infinity_and_nan, + constexpr Parse_options(bool allow_infinity_and_nan, bool allow_explicit_plus_sign_in_mantissa, bool allow_single_quote_strings, bool allow_number_to_start_with_dot) noexcept @@ -226,17 +226,17 @@ struct parse_options allow_number_to_start_with_dot(allow_number_to_start_with_dot) { } - static constexpr parse_options default_options() noexcept + static constexpr Parse_options default_options() noexcept { - return parse_options(); + return Parse_options(); } - static constexpr parse_options relaxed_options() noexcept + static constexpr Parse_options relaxed_options() noexcept { - return parse_options(true, true, true, true); + return Parse_options(true, true, true, true); } }; -ast::value parse(const source *source, parse_options options = parse_options::default_options()); +ast::Value parse(const Source *source, Parse_options options = Parse_options::default_options()); } } diff --git a/src/spirv/spirv.h b/src/spirv/spirv.h index 5e564c2..e9cac89 100644 --- a/src/spirv/spirv.h +++ b/src/spirv/spirv.h @@ -30,8 +30,8 @@ namespace vulkan_cpu { namespace spirv { -typedef std::uint32_t word; -constexpr word magic_number = 0x07230203UL; +typedef std::uint32_t Word; +constexpr Word magic_number = 0x07230203UL; } } diff --git a/src/util/invoke.h b/src/util/invoke.h index 9680040..1a2b801 100644 --- a/src/util/invoke.h +++ b/src/util/invoke.h @@ -60,13 +60,13 @@ constexpr decltype(auto) invoke_member_function_pointer( } template -struct invoke_is_reference_wrapper +struct Invoke_is_reference_wrapper { static constexpr bool value = false; }; template -struct invoke_is_reference_wrapper> +struct Invoke_is_reference_wrapper> { static constexpr bool value = true; }; @@ -78,7 +78,7 @@ template < typename... Args, typename = int, typename = typename std::enable_if::type>::value - && invoke_is_reference_wrapper< + && Invoke_is_reference_wrapper< typename std::decay::type>::value>::type> constexpr decltype(auto) invoke_member_function_pointer( Fn T::*fn, @@ -96,7 +96,7 @@ template < typename = int, typename = int, typename = typename std::enable_if::type>::value - && !invoke_is_reference_wrapper< + && !Invoke_is_reference_wrapper< typename std::decay::type>::value>::type> constexpr decltype(auto) invoke_member_function_pointer( Fn T::*fn, Arg1 &&arg1, Args &&... args) noexcept(noexcept(((*std::forward(arg1)) @@ -133,7 +133,7 @@ template < typename Arg, typename = int, typename = typename std::enable_if::type>::value - && invoke_is_reference_wrapper< + && Invoke_is_reference_wrapper< typename std::decay::type>::value>::type> constexpr decltype(auto) invoke_member_object_pointer(Fn T::*fn, Arg &&arg) noexcept(noexcept(arg.get().*fn)) @@ -148,7 +148,7 @@ template < typename = int, typename = int, typename = typename std::enable_if::type>::value - && !invoke_is_reference_wrapper< + && !Invoke_is_reference_wrapper< typename std::decay::type>::value>::type> constexpr decltype(auto) invoke_member_object_pointer(Fn T::*fn, Arg &&arg) noexcept( noexcept((*std::forward(arg)).*fn)) @@ -166,7 +166,7 @@ constexpr decltype(auto) invoke_helper(Fn fn, Arg &&arg) noexcept( } template -struct invoke_result_helper +struct Invoke_result_helper { static constexpr bool is_invokable = false; static constexpr bool is_nothrow_invokable = false; @@ -183,7 +183,7 @@ struct invoke_result_helper }; template -struct invoke_result_helper(), std::declval()...))>, Args...> @@ -218,7 +218,7 @@ struct invoke_result_helper -struct invoke_result : public detail::invoke_result_helper +struct invoke_result : public detail::Invoke_result_helper { }; @@ -234,7 +234,7 @@ constexpr invoke_result_t invoke(Fn &&fn, Args &&... args) noexcept template struct is_invocable - : public std::integral_constant::is_invokable> + : public std::integral_constant::is_invokable> { }; @@ -243,8 +243,9 @@ constexpr bool is_invocable_v = is_invocable::value; template struct is_invocable_r - : public std::integral_constant::template is_invokable_r()> + : public std:: + integral_constant::template is_invokable_r()> { }; @@ -254,7 +255,7 @@ constexpr bool is_invocable_r_v = is_invocable_r::value; template struct is_nothrow_invocable : public std::integral_constant::is_nothrow_invokable> + detail::Invoke_result_helper::is_nothrow_invokable> { }; @@ -263,9 +264,9 @@ constexpr bool is_nothrow_invocable_v = is_nothrow_invocable::value template struct is_nothrow_invocable_r - : public std:: - integral_constant::template is_nothrow_invokable_r()> + : public std::integral_constant:: + template is_nothrow_invokable_r()> { }; diff --git a/src/util/is_swappable.h b/src/util/is_swappable.h index 483fb33..a6cb631 100644 --- a/src/util/is_swappable.h +++ b/src/util/is_swappable.h @@ -32,7 +32,7 @@ namespace vulkan_cpu_util_is_swappable_unrelated_namespace { using std::swap; template ::value || std::is_void::value> -class is_swappable_with +class Is_swappable_with { private: template -class is_swappable_with +class Is_swappable_with { public: static constexpr bool value = false; }; -template ::value> -struct is_nothrow_swappable_with +template ::value> +struct Is_nothrow_swappable_with { static constexpr bool value = noexcept(swap(std::declval(), std::declval())) && noexcept(swap(std::declval(), std::declval())); }; template -struct is_nothrow_swappable_with +struct Is_nothrow_swappable_with { static constexpr bool value = false; }; @@ -76,7 +76,7 @@ template struct is_swappable_with : public std::integral_constant::value> + Is_swappable_with::value> { }; @@ -87,7 +87,7 @@ template struct is_nothrow_swappable_with : public std::integral_constant::value> + Is_nothrow_swappable_with::value> { }; diff --git a/src/util/optional.h b/src/util/optional.h index 25f0e40..7144707 100644 --- a/src/util/optional.h +++ b/src/util/optional.h @@ -62,7 +62,7 @@ namespace detail template ::value, bool Is_Trivially_Copyable = std::is_trivially_copyable::value> -struct optional_base +struct Optional_base { union { @@ -70,10 +70,10 @@ struct optional_base alignas(T) char empty_value[sizeof(T)]; }; bool is_full; - constexpr optional_base() noexcept : empty_value{}, is_full(false) + constexpr Optional_base() noexcept : empty_value{}, is_full(false) { } - constexpr optional_base(nullopt_t) noexcept : empty_value{}, is_full(false) + constexpr Optional_base(nullopt_t) noexcept : empty_value{}, is_full(false) { } void reset() noexcept @@ -103,13 +103,13 @@ struct optional_base is_full = true; return full_value; } - optional_base(const optional_base &rt) noexcept(std::is_nothrow_copy_constructible::value) + Optional_base(const Optional_base &rt) noexcept(std::is_nothrow_copy_constructible::value) : empty_value{}, is_full(false) { if(rt.is_full) emplace(rt.full_value); } - optional_base(optional_base &&rt) noexcept(std::is_nothrow_move_constructible::value) + Optional_base(Optional_base &&rt) noexcept(std::is_nothrow_move_constructible::value) : empty_value{}, is_full(false) { if(rt.is_full) @@ -117,7 +117,7 @@ struct optional_base } template ::value>::type> - constexpr explicit optional_base(in_place_t, Types &&... args) noexcept( + constexpr explicit Optional_base(in_place_t, Types &&... args) noexcept( std::is_nothrow_constructible::value) : full_value(std::forward(args)...), is_full(true) { @@ -127,18 +127,18 @@ struct optional_base typename... Types, typename = typename std:: enable_if, Types...>::value>::type> - constexpr explicit optional_base( + constexpr explicit Optional_base( in_place_t, std::initializer_list init_list, Types &&... args) noexcept(std::is_nothrow_constructible::value) : full_value(init_list, std::forward(args)...), is_full(true) { } - ~optional_base() + ~Optional_base() { reset(); } - optional_base &operator=(const optional_base &rt) noexcept( + Optional_base &operator=(const Optional_base &rt) noexcept( std::is_nothrow_copy_assignable::value) { if(!rt.is_full) @@ -149,7 +149,7 @@ struct optional_base full_value = rt.full_value; return *this; } - optional_base &operator=(optional_base &&rt) noexcept(std::is_nothrow_move_assignable::value) + Optional_base &operator=(Optional_base &&rt) noexcept(std::is_nothrow_move_assignable::value) { if(!rt.is_full) reset(); @@ -162,7 +162,7 @@ struct optional_base }; template -struct optional_base +struct Optional_base { union { @@ -170,10 +170,10 @@ struct optional_base alignas(T) char empty_value[sizeof(T)]; }; bool is_full; - constexpr optional_base() noexcept : empty_value{}, is_full(false) + constexpr Optional_base() noexcept : empty_value{}, is_full(false) { } - constexpr optional_base(nullopt_t) noexcept : empty_value{}, is_full(false) + constexpr Optional_base(nullopt_t) noexcept : empty_value{}, is_full(false) { } void reset() noexcept @@ -202,13 +202,13 @@ struct optional_base is_full = true; return full_value; } - optional_base(const optional_base &rt) noexcept(std::is_nothrow_copy_constructible::value) + Optional_base(const Optional_base &rt) noexcept(std::is_nothrow_copy_constructible::value) : empty_value{}, is_full(false) { if(rt.is_full) emplace(rt.full_value); } - optional_base(optional_base &&rt) noexcept(std::is_nothrow_move_constructible::value) + Optional_base(Optional_base &&rt) noexcept(std::is_nothrow_move_constructible::value) : empty_value{}, is_full(false) { if(rt.is_full) @@ -216,7 +216,7 @@ struct optional_base } template ::value>::type> - constexpr explicit optional_base(in_place_t, Types &&... args) noexcept( + constexpr explicit Optional_base(in_place_t, Types &&... args) noexcept( std::is_nothrow_constructible::value) : full_value(std::forward(args)...), is_full(true) { @@ -226,15 +226,15 @@ struct optional_base typename... Types, typename = typename std:: enable_if, Types...>::value>::type> - constexpr explicit optional_base( + constexpr explicit Optional_base( in_place_t, std::initializer_list init_list, Types &&... args) noexcept(std::is_nothrow_constructible::value) : full_value(init_list, std::forward(args)...), is_full(true) { } - ~optional_base() = default; - optional_base &operator=(const optional_base &rt) noexcept( + ~Optional_base() = default; + Optional_base &operator=(const Optional_base &rt) noexcept( std::is_nothrow_copy_assignable::value) { if(!rt.is_full) @@ -245,7 +245,7 @@ struct optional_base full_value = rt.full_value; return *this; } - optional_base &operator=(optional_base &&rt) noexcept(std::is_nothrow_move_assignable::value) + Optional_base &operator=(Optional_base &&rt) noexcept(std::is_nothrow_move_assignable::value) { if(!rt.is_full) reset(); @@ -258,7 +258,7 @@ struct optional_base }; template -struct optional_base +struct Optional_base { union { @@ -266,10 +266,10 @@ struct optional_base alignas(T) char empty_value[sizeof(T)]; }; bool is_full; - constexpr optional_base() noexcept : empty_value{}, is_full(false) + constexpr Optional_base() noexcept : empty_value{}, is_full(false) { } - constexpr optional_base(nullopt_t) noexcept : empty_value{}, is_full(false) + constexpr Optional_base(nullopt_t) noexcept : empty_value{}, is_full(false) { } void reset() noexcept @@ -298,11 +298,11 @@ struct optional_base is_full = true; return full_value; } - constexpr optional_base(const optional_base &rt) noexcept = default; - constexpr optional_base(optional_base &&rt) noexcept = default; + constexpr Optional_base(const Optional_base &rt) noexcept = default; + constexpr Optional_base(Optional_base &&rt) noexcept = default; template ::value>::type> - constexpr explicit optional_base(in_place_t, Types &&... args) noexcept( + constexpr explicit Optional_base(in_place_t, Types &&... args) noexcept( std::is_nothrow_constructible::value) : full_value(std::forward(args)...), is_full(true) { @@ -312,16 +312,16 @@ struct optional_base typename... Types, typename = typename std:: enable_if, Types...>::value>::type> - constexpr explicit optional_base( + constexpr explicit Optional_base( in_place_t, std::initializer_list init_list, Types &&... args) noexcept(std::is_nothrow_constructible::value) : full_value(init_list, std::forward(args)...), is_full(true) { } - ~optional_base() = default; - optional_base &operator=(const optional_base &rt) noexcept = default; - optional_base &operator=(optional_base &&rt) noexcept = default; + ~Optional_base() = default; + Optional_base &operator=(const Optional_base &rt) noexcept = default; + Optional_base &operator=(Optional_base &&rt) noexcept = default; }; } @@ -390,25 +390,25 @@ constexpr bool optional_needs_conversion_from_optional_assign_operators() noexce } template -class optional : private detail::optional_base +class optional : private detail::Optional_base { private: - typedef detail::optional_base base; - using base::is_full; - using base::full_value; + typedef detail::Optional_base Base; + using Base::is_full; + using Base::full_value; public: - using base::base; - using base::operator=; - using base::reset; - using base::emplace; + using Base::Base; + using Base::operator=; + using Base::reset; + using Base::emplace; constexpr optional() noexcept = default; template () && std::is_convertible::value>::type> optional(const optional &rt) noexcept(std::is_nothrow_constructible::value) - : base() + : Base() { if(rt) emplace(*rt); @@ -420,7 +420,7 @@ public: typename = void> explicit optional(const optional &rt) noexcept( std::is_nothrow_constructible::value) - : base() + : Base() { if(rt) emplace(*rt); @@ -431,7 +431,7 @@ public: typename std::enable_if() && std::is_convertible::value>::type> optional(optional &&rt) noexcept(std::is_nothrow_constructible::value) - : base() + : Base() { if(rt) emplace(std::move(*rt)); @@ -443,7 +443,7 @@ public: && !std::is_convertible::value>::type, typename = void> explicit optional(optional &&rt) noexcept(std::is_nothrow_constructible::value) - : base() + : Base() { if(rt) emplace(std::move(*rt)); @@ -456,7 +456,7 @@ public: && std::is_convertible::value>::type, typename = void> constexpr optional(U &&value) noexcept(std::is_nothrow_constructible::value) - : base(in_place, std::forward(value)) + : Base(in_place, std::forward(value)) { } template ::type, optional>::value && !std::is_convertible::value>::type> explicit constexpr optional(U &&value) noexcept(std::is_nothrow_constructible::value) - : base(in_place, std::forward(value)) + : Base(in_place, std::forward(value)) { } template ::type; namespace detail { -struct variant_base_construct_tag +struct Variant_base_construct_tag { - explicit variant_base_construct_tag() = default; + explicit Variant_base_construct_tag() = default; }; template -struct variant_identity_type +struct Variant_identity_type { typedef T type; }; template -struct variant_hypothetical_overload_set; +struct Variant_hypothetical_overload_set; template -struct variant_hypothetical_overload_set - : public variant_hypothetical_overload_set +struct Variant_hypothetical_overload_set + : public Variant_hypothetical_overload_set { - using variant_hypothetical_overload_set::fn; - static variant_identity_type fn(T); // not implemented + using Variant_hypothetical_overload_set::fn; + static Variant_identity_type fn(T); // not implemented }; template <> -struct variant_hypothetical_overload_set<> +struct Variant_hypothetical_overload_set<> { static void fn(); // not implemented }; template -struct variant_is_equals_comparable +struct Variant_is_equals_comparable { private: static std::false_type fn(...); @@ -197,7 +197,7 @@ public: }; template -struct variant_is_less_comparable +struct Variant_is_less_comparable { private: static std::false_type fn(...); @@ -211,7 +211,7 @@ public: }; template -struct variant_is_nothrow_equals_comparable +struct Variant_is_nothrow_equals_comparable { private: static std::false_type fn(...); @@ -226,7 +226,7 @@ public: }; template -struct variant_is_nothrow_less_comparable +struct Variant_is_nothrow_less_comparable { private: static std::false_type fn(...); @@ -253,7 +253,7 @@ constexpr bool variant_is_trivially_destructible() noexcept } template -union variant_values_implementation +union Variant_values_implementation { char value; static constexpr bool is_copy_constructible = true; @@ -270,9 +270,9 @@ union variant_values_implementation static constexpr bool is_less_comparable = true; static constexpr bool is_nothrow_equals_comparable = true; static constexpr bool is_nothrow_less_comparable = true; - variant_values_implementation() = delete; + Variant_values_implementation() = delete; template - constexpr variant_values_implementation(in_place_index_t) noexcept : value() + constexpr Variant_values_implementation(in_place_index_t) noexcept : value() { } template @@ -280,43 +280,43 @@ union variant_values_implementation { return variant_npos; } - void copy_construct(const variant_values_implementation &rt, std::size_t index) noexcept + void copy_construct(const Variant_values_implementation &rt, std::size_t index) noexcept { } - void move_construct(variant_values_implementation &&rt, std::size_t index) noexcept + void move_construct(Variant_values_implementation &&rt, std::size_t index) noexcept { } - void copy_assign(const variant_values_implementation &rt, std::size_t index) noexcept + void copy_assign(const Variant_values_implementation &rt, std::size_t index) noexcept { } - void move_assign(variant_values_implementation &&rt, std::size_t index) noexcept + void move_assign(Variant_values_implementation &&rt, std::size_t index) noexcept { } void destruct(std::size_t index) noexcept { } - void swap(variant_values_implementation &rt, std::size_t index) noexcept + void swap(Variant_values_implementation &rt, std::size_t index) noexcept { } - bool is_equal(const variant_values_implementation &rt, std::size_t index) const noexcept + bool is_equal(const Variant_values_implementation &rt, std::size_t index) const noexcept { return true; } - bool is_less(const variant_values_implementation &rt, std::size_t index) const noexcept + bool is_less(const Variant_values_implementation &rt, std::size_t index) const noexcept { return false; } }; template -using variant_values = - variant_values_implementation(), Types...>; +using Variant_values = + Variant_values_implementation(), Types...>; #define VULKAN_CPU_UTIL_VARIANT_VALUES(Is_Trivially_Destructible, Destructor) \ template \ - union variant_values_implementation \ + union Variant_values_implementation \ { \ - typedef T type_0; \ + typedef T Type_0; \ static_assert(!std::is_void::value, "invalid variant member type"); \ static_assert(!std::is_reference::value, "invalid variant member type"); \ static_assert(!std::is_array::value, "invalid variant member type"); \ @@ -324,68 +324,68 @@ using variant_values = static_assert(!std::is_volatile::value, "invalid variant member type"); \ static_assert(std::is_object::value, "invalid variant member type"); \ T current_value; \ - variant_values_implementation other_values; \ + Variant_values_implementation other_values; \ static constexpr bool is_copy_constructible = \ std::is_copy_constructible::value \ - && variant_values_implementation::is_copy_constructible; \ static constexpr bool is_move_constructible = \ std::is_move_constructible::value \ - && variant_values_implementation::is_move_constructible; \ static constexpr bool is_nothrow_copy_constructible = \ std::is_nothrow_copy_constructible::value \ - && variant_values_implementation::is_nothrow_copy_constructible; \ static constexpr bool is_nothrow_move_constructible = \ std::is_nothrow_move_constructible::value \ - && variant_values_implementation::is_nothrow_move_constructible; \ static constexpr bool is_copy_assignable = \ std::is_copy_assignable::value && std::is_copy_constructible::value \ - && variant_values_implementation::is_copy_assignable; \ static constexpr bool is_move_assignable = \ std::is_move_assignable::value && std::is_move_constructible::value \ - && variant_values_implementation::is_move_assignable; \ static constexpr bool is_nothrow_copy_assignable = \ std::is_nothrow_copy_assignable::value \ && std::is_nothrow_copy_constructible::value \ - && variant_values_implementation::is_nothrow_copy_assignable; \ static constexpr bool is_nothrow_move_assignable = \ std::is_nothrow_move_assignable::value \ && std::is_nothrow_move_constructible::value \ - && variant_values_implementation::is_nothrow_move_assignable; \ static constexpr bool is_swappable = \ is_swappable_v && std::is_move_constructible::value \ - && variant_values_implementation::is_swappable; \ + && Variant_values_implementation::is_swappable; \ static constexpr bool is_nothrow_swappable = \ is_nothrow_swappable_v && std::is_nothrow_move_constructible::value \ - && variant_values_implementation::is_nothrow_swappable; \ static constexpr bool is_equals_comparable = \ - variant_is_equals_comparable::value \ - && variant_values_implementation::value \ + && Variant_values_implementation::is_equals_comparable; \ static constexpr bool is_less_comparable = \ - variant_is_less_comparable::value \ - && variant_values_implementation::value \ + && Variant_values_implementation::is_less_comparable; \ static constexpr bool is_nothrow_equals_comparable = \ - variant_is_nothrow_equals_comparable::value \ - && variant_values_implementation::value \ + && Variant_values_implementation::is_nothrow_equals_comparable; \ static constexpr bool is_nothrow_less_comparable = \ - variant_is_nothrow_less_comparable::value \ - && variant_values_implementation::value \ + && Variant_values_implementation::is_nothrow_less_comparable; \ template < \ typename T2 = T, \ typename = typename std::enable_if::value>::type> \ - constexpr variant_values_implementation() noexcept( \ + constexpr Variant_values_implementation() noexcept( \ std::is_nothrow_default_constructible::value) \ : current_value() \ { \ @@ -393,7 +393,7 @@ using variant_values = template < \ typename... Args, \ typename = typename std::enable_if::value>::type> \ - constexpr variant_values_implementation(in_place_index_t<0>, Args &&... args) noexcept( \ + constexpr Variant_values_implementation(in_place_index_t<0>, Args &&... args) noexcept( \ std::is_nothrow_constructible::value) \ : current_value(std::forward(args)...) \ { \ @@ -403,12 +403,12 @@ using variant_values = typename = typename std:: \ enable_if, \ in_place_index_t, \ Args...>::value>::type> \ - constexpr variant_values_implementation(in_place_index_t, Args &&... args) noexcept( \ - std::is_nothrow_constructible, Args &&... args) noexcept( \ + std::is_nothrow_constructible, \ in_place_index_t, \ Args...>::value) \ @@ -421,7 +421,7 @@ using variant_values = typename = typename std::enable_if, \ Args...>::value>::type> \ - constexpr variant_values_implementation( \ + constexpr Variant_values_implementation( \ in_place_index_t<0>, \ std::initializer_list il, \ Args &&... args) noexcept(std::is_nothrow_constructible::template index_from_type(); \ if(std::is_same::value && next == variant_npos) \ return 0; \ @@ -442,7 +442,7 @@ using variant_values = return variant_npos; \ return next + 1; \ } \ - void copy_construct(const variant_values_implementation &rt, \ + void copy_construct(const Variant_values_implementation &rt, \ std::size_t index) noexcept(is_nothrow_copy_constructible) \ { \ if(index == 0) \ @@ -451,7 +451,7 @@ using variant_values = else \ other_values.copy_construct(rt.other_values, index - 1); \ } \ - void move_construct(variant_values_implementation &&rt, \ + void move_construct(Variant_values_implementation &&rt, \ std::size_t index) noexcept(is_nothrow_move_constructible) \ { \ if(index == 0) \ @@ -460,7 +460,7 @@ using variant_values = else \ other_values.move_construct(std::move(rt.other_values), index - 1); \ } \ - void copy_assign(const variant_values_implementation &rt, \ + void copy_assign(const Variant_values_implementation &rt, \ std::size_t index) noexcept(is_nothrow_copy_assignable) \ { \ if(index == 0) \ @@ -468,7 +468,7 @@ using variant_values = else \ other_values.copy_assign(rt.other_values, index - 1); \ } \ - void move_assign(variant_values_implementation &&rt, \ + void move_assign(Variant_values_implementation &&rt, \ std::size_t index) noexcept(is_nothrow_move_assignable) \ { \ if(index == 0) \ @@ -483,7 +483,7 @@ using variant_values = else \ other_values.destruct(index - 1); \ } \ - void swap(variant_values_implementation &rt, \ + void swap(Variant_values_implementation &rt, \ std::size_t index) noexcept(is_nothrow_swappable) \ { \ using std::swap; \ @@ -492,14 +492,14 @@ using variant_values = else \ other_values.swap(rt.other_values, index - 1); \ } \ - bool is_equal(const variant_values_implementation &rt, std::size_t index) const \ + bool is_equal(const Variant_values_implementation &rt, std::size_t index) const \ noexcept(is_nothrow_equals_comparable) \ { \ if(index == 0) \ return static_cast(current_value == rt.current_value); \ return other_values.is_equal(rt.other_values, index - 1); \ } \ - bool is_less(const variant_values_implementation &rt, std::size_t index) const \ + bool is_less(const Variant_values_implementation &rt, std::size_t index) const \ noexcept(is_nothrow_less_comparable) \ { \ if(index == 0) \ @@ -509,54 +509,54 @@ using variant_values = Destructor \ }; -VULKAN_CPU_UTIL_VARIANT_VALUES(true, ~variant_values_implementation() = default;) -VULKAN_CPU_UTIL_VARIANT_VALUES(false, ~variant_values_implementation(){}) +VULKAN_CPU_UTIL_VARIANT_VALUES(true, ~Variant_values_implementation() = default;) +VULKAN_CPU_UTIL_VARIANT_VALUES(false, ~Variant_values_implementation(){}) #undef VULKAN_CPU_UTIL_VARIANT_VALUES template -struct variant_get; +struct Variant_get; template -struct variant_get +struct Variant_get { - static constexpr auto get(const variant_values &values) noexcept - -> decltype(variant_get::get(values.other_values)) + static constexpr auto get(const Variant_values &values) noexcept + -> decltype(Variant_get::get(values.other_values)) { - return variant_get::get(values.other_values); + return Variant_get::get(values.other_values); } - static constexpr auto get(variant_values &values) noexcept - -> decltype(variant_get::get(values.other_values)) + static constexpr auto get(Variant_values &values) noexcept + -> decltype(Variant_get::get(values.other_values)) { - return variant_get::get(values.other_values); + return Variant_get::get(values.other_values); } - static constexpr auto get(const variant_values &&values) noexcept - -> decltype(variant_get::get(std::move(values.other_values))) + static constexpr auto get(const Variant_values &&values) noexcept + -> decltype(Variant_get::get(std::move(values.other_values))) { - return variant_get::get(std::move(values.other_values)); + return Variant_get::get(std::move(values.other_values)); } - static constexpr auto get(variant_values &&values) noexcept - -> decltype(variant_get::get(std::move(values.other_values))) + static constexpr auto get(Variant_values &&values) noexcept + -> decltype(Variant_get::get(std::move(values.other_values))) { - return variant_get::get(std::move(values.other_values)); + return Variant_get::get(std::move(values.other_values)); } }; template -struct variant_get<0, T, Types...> +struct Variant_get<0, T, Types...> { - static constexpr const T &get(const variant_values &values) noexcept + static constexpr const T &get(const Variant_values &values) noexcept { return values.current_value; } - static constexpr T &get(variant_values &values) noexcept + static constexpr T &get(Variant_values &values) noexcept { return values.current_value; } - static constexpr const T &&get(const variant_values &&values) noexcept + static constexpr const T &&get(const Variant_values &&values) noexcept { return std::move(values.current_value); } - static constexpr T &&get(variant_values &&values) noexcept + static constexpr T &&get(Variant_values &&values) noexcept { return std::move(values.current_value); } @@ -569,10 +569,10 @@ struct variant_get<0, T, Types...> typename... Types, \ typename... Args> \ constexpr Return_Type variant_dispatch_helper_dispatch_function( \ - Fn &&fn, Const variant_values Ref values, Args &&... args) \ + Fn &&fn, Const Variant_values Ref values, Args &&... args) \ { \ - return std::forward(fn)(variant_get::get( \ - std::forward Ref>(values)), \ + return std::forward(fn)(Variant_get::get( \ + std::forward Ref>(values)), \ std::forward(args)...); \ } \ \ @@ -583,37 +583,37 @@ struct variant_get<0, T, Types...> typename Return_Type = typename std::common_type()( \ std::declval(), std::declval()...))...>::type> \ constexpr Return_Type variant_dispatch_helper(Fn &&fn, \ - Const variant_values Ref values, \ + Const Variant_values Ref values, \ std::size_t index, \ std::index_sequence, \ Args &&... args) \ { \ - typedef Return_Type (*Dispatch_Function)( \ - Fn && fn, Const variant_values Ref values, Args && ... args); \ - const Dispatch_Function dispatch_functions[sizeof...(Types)] = { \ - static_cast( \ + typedef Return_Type (*Dispatch_function)( \ + Fn && fn, Const Variant_values Ref values, Args && ... args); \ + const Dispatch_function dispatch_functions[sizeof...(Types)] = { \ + static_cast( \ &variant_dispatch_helper_dispatch_function)..., \ }; \ if(index < sizeof...(Types)) \ return dispatch_functions[index]( \ std::forward(fn), \ - std::forward Ref>(values), \ + std::forward Ref>(values), \ std::forward(args)...); \ throw bad_variant_access(); \ } \ \ template \ constexpr auto variant_dispatch( \ - Fn &&fn, Const variant_values Ref values, std::size_t index, Args &&... args) \ + Fn &&fn, Const Variant_values Ref values, std::size_t index, Args &&... args) \ ->decltype( \ variant_dispatch_helper(std::forward(fn), \ - std::forward Ref>(values), \ + std::forward Ref>(values), \ index, \ std::index_sequence_for{}, \ std::forward(args)...)) \ { \ return variant_dispatch_helper(std::forward(fn), \ - std::forward Ref>(values), \ + std::forward Ref>(values), \ index, \ std::index_sequence_for{}, \ std::forward(args)...); \ @@ -627,38 +627,38 @@ struct variant_get<0, T, Types...> std::declval(), std::declval()...))...>::type> \ constexpr Return_Type variant_dispatch_helper_nothrow( \ Fn &&fn, \ - Const variant_values Ref values, \ + Const Variant_values Ref values, \ std::size_t index, \ std::index_sequence, \ Args &&... args) \ { \ - typedef Return_Type (*Dispatch_Function)( \ - Fn && fn, Const variant_values Ref values, Args && ... args); \ - const Dispatch_Function dispatch_functions[sizeof...(Types)] = { \ - static_cast( \ + typedef Return_Type (*Dispatch_function)( \ + Fn && fn, Const Variant_values Ref values, Args && ... args); \ + const Dispatch_function dispatch_functions[sizeof...(Types)] = { \ + static_cast( \ &variant_dispatch_helper_dispatch_function)..., \ }; \ if(index < sizeof...(Types)) \ return dispatch_functions[index]( \ std::forward(fn), \ - std::forward Ref>(values), \ + std::forward Ref>(values), \ std::forward(args)...); \ return {}; \ } \ \ template \ constexpr auto variant_dispatch_nothrow( \ - Fn &&fn, Const variant_values Ref values, std::size_t index, Args &&... args) \ + Fn &&fn, Const Variant_values Ref values, std::size_t index, Args &&... args) \ ->decltype(variant_dispatch_helper_nothrow( \ std::forward(fn), \ - std::forward Ref>(values), \ + std::forward Ref>(values), \ index, \ std::index_sequence_for{}, \ std::forward(args)...)) \ { \ return variant_dispatch_helper_nothrow( \ std::forward(fn), \ - std::forward Ref>(values), \ + std::forward Ref>(values), \ index, \ std::index_sequence_for{}, \ std::forward(args)...); \ @@ -671,7 +671,7 @@ VULKAN_CPU_UTIL_VARIANT_DISPATCH(const, &&) #undef VULKAN_CPU_UTIL_VARIANT_DISPATCH template -struct variant_index_type +struct Variant_index_type { static constexpr std::size_t total_state_count = Type_Count + 1; // for valueless-by-exception state @@ -687,22 +687,22 @@ struct variant_index_type total_state_count <= std::numeric_limits::max(); typedef typename std::conditional::type - unsigned_long_long_or_larger; + Unsigned_long_long_or_larger; typedef typename std::conditional::type unsigned_long_or_larger; - typedef typename std::conditional::type - unsigned_or_larger; + Unsigned_long_long_or_larger>::type Unsigned_long_or_larger; + typedef typename std::conditional::type + Unsigned_or_larger; typedef - typename std::conditional::type - unsigned_short_or_larger; + typename std::conditional::type + Unsigned_short_or_larger; typedef typename std::conditional::type type; + Unsigned_short_or_larger>::type type; static constexpr type npos = variant_npos; type index_value; - constexpr variant_index_type() = delete; - constexpr explicit variant_index_type(std::size_t index_value) noexcept + constexpr Variant_index_type() = delete; + constexpr explicit Variant_index_type(std::size_t index_value) noexcept : index_value(index_value) { } @@ -722,19 +722,19 @@ template -struct variant_base; +struct Variant_base; #define VULKAN_CPU_UTIL_VARIANT_BASE_DESTRUCTOR_false \ - ~variant_base() \ + ~Variant_base() \ { \ values.destruct(index_value.get()); \ } -#define VULKAN_CPU_UTIL_VARIANT_BASE_DESTRUCTOR_true ~variant_base() = default; +#define VULKAN_CPU_UTIL_VARIANT_BASE_DESTRUCTOR_true ~Variant_base() = default; #define VULKAN_CPU_UTIL_VARIANT_BASE_COPY_CONSTRUCTOR_true \ - variant_base(const variant_base &rt) noexcept( \ - detail::variant_values::is_nothrow_copy_constructible) \ + Variant_base(const Variant_base &rt) noexcept( \ + Variant_values::is_nothrow_copy_constructible) \ : values(in_place_index), index_value(variant_npos) \ { \ values.copy_construct(rt.values, rt.index_value.get()); \ @@ -742,11 +742,11 @@ struct variant_base; } #define VULKAN_CPU_UTIL_VARIANT_BASE_COPY_CONSTRUCTOR_false \ - variant_base(const variant_base &rt) = delete; + Variant_base(const Variant_base &rt) = delete; #define VULKAN_CPU_UTIL_VARIANT_BASE_MOVE_CONSTRUCTOR_true \ - variant_base(variant_base &&rt) noexcept( \ - detail::variant_values::is_nothrow_move_constructible) \ + Variant_base(Variant_base &&rt) noexcept( \ + Variant_values::is_nothrow_move_constructible) \ : values(in_place_index), index_value(variant_npos) \ { \ values.move_construct(std::move(rt.values), rt.index_value.get()); \ @@ -754,11 +754,11 @@ struct variant_base; } #define VULKAN_CPU_UTIL_VARIANT_BASE_MOVE_CONSTRUCTOR_false \ - variant_base(variant_base &&rt) = delete; + Variant_base(Variant_base &&rt) = delete; #define VULKAN_CPU_UTIL_VARIANT_BASE_COPY_ASSIGN_OP_true \ - variant_base &operator=(const variant_base &rt) noexcept( \ - detail::variant_values::is_nothrow_copy_assignable) \ + Variant_base &operator=(const Variant_base &rt) noexcept( \ + Variant_values::is_nothrow_copy_assignable) \ { \ if(index_value.get() == rt.index_value.get()) \ { \ @@ -775,11 +775,11 @@ struct variant_base; } #define VULKAN_CPU_UTIL_VARIANT_BASE_COPY_ASSIGN_OP_false \ - variant_base &operator=(const variant_base &rt) = delete; + Variant_base &operator=(const Variant_base &rt) = delete; #define VULKAN_CPU_UTIL_VARIANT_BASE_MOVE_ASSIGN_OP_true \ - variant_base &operator=(variant_base &&rt) noexcept( \ - detail::variant_values::is_nothrow_move_assignable) \ + Variant_base &operator=(Variant_base &&rt) noexcept( \ + Variant_values::is_nothrow_move_assignable) \ { \ if(index_value.get() == rt.index_value.get()) \ { \ @@ -796,7 +796,7 @@ struct variant_base; } #define VULKAN_CPU_UTIL_VARIANT_BASE_MOVE_ASSIGN_OP_false \ - variant_base &operator=(variant_base &&rt) = delete; + Variant_base &operator=(Variant_base &&rt) = delete; #define VULKAN_CPU_UTIL_VARIANT_BASE0(Is_Trivially_Destructible, \ Is_Copy_Constructible, \ @@ -804,21 +804,21 @@ struct variant_base; Is_Copy_Assignable, \ Is_Move_Assignable) \ template \ - struct variant_base \ { \ - detail::variant_values values; \ - detail::variant_index_type index_value; \ + Variant_values values; \ + Variant_index_type index_value; \ template \ - constexpr variant_base( \ - variant_base_construct_tag, \ + constexpr Variant_base( \ + Variant_base_construct_tag, \ std::size_t index_value, \ Args &&... args) noexcept(noexcept(new(std::declval()) \ - detail::variant_values( \ + Variant_values( \ std::declval()...))) \ : values(std::forward(args)...), index_value(index_value) \ { \ @@ -862,25 +862,25 @@ VULKAN_CPU_UTIL_VARIANT_BASE4(false) VULKAN_CPU_UTIL_VARIANT_BASE4(true) template -struct variant_is_in_place_index +struct Variant_is_in_place_index { static constexpr bool value = false; }; template -struct variant_is_in_place_index> +struct Variant_is_in_place_index> { static constexpr bool value = true; }; template -struct variant_is_in_place_type +struct Variant_is_in_place_type { static constexpr bool value = false; }; template -struct variant_is_in_place_type> +struct Variant_is_in_place_type> { static constexpr bool value = true; }; @@ -902,51 +902,51 @@ typename std::common_type()(std::declval &&v, Args &&... args); template -using variant_base_t = variant_base(), - detail::variant_values::is_copy_constructible, - detail::variant_values::is_move_constructible, - detail::variant_values::is_copy_assignable, - detail::variant_values::is_move_assignable, +using Variant_base_t = Variant_base(), + Variant_values::is_copy_constructible, + Variant_values::is_move_constructible, + Variant_values::is_copy_assignable, + Variant_values::is_move_assignable, Types...>; } template -class variant : private detail::variant_base_t +class variant : private detail::Variant_base_t { static_assert(sizeof...(Types) > 0, "empty variant is not permitted"); private: - typedef typename detail::variant_values::type_0 type_0; - typedef detail::variant_base_t base; + typedef typename detail::Variant_values::Type_0 Type_0; + typedef detail::Variant_base_t Base; private: - using base::values; - using base::index_value; + using Base::values; + using Base::index_value; public: template ::value>::type> - constexpr variant() noexcept(std::is_nothrow_default_constructible::value) - : base(detail::variant_base_construct_tag{}, 0) + enable_if::value>::type> + constexpr variant() noexcept(std::is_nothrow_default_constructible::value) + : Base(detail::Variant_base_construct_tag{}, 0) { } template < typename T, typename Deduced_Type = typename decltype( - detail::variant_hypothetical_overload_set::fn(std::declval()))::type, + detail::Variant_hypothetical_overload_set::fn(std::declval()))::type, std::size_t Index = - detail::variant_values::template index_from_type(), + detail::Variant_values::template index_from_type(), typename = typename std:: enable_if<(Index < sizeof...(Types)) && !std::is_same::type, variant>::value - && !detail::variant_is_in_place_index::type>::value - && !detail::variant_is_in_place_type::type>::value + && !detail::Variant_is_in_place_index::type>::value + && !detail::Variant_is_in_place_type::type>::value && std::is_constructible>, T>::value>::type> constexpr variant(T &&value) noexcept( std::is_nothrow_constructible>, T>::value) - : base(detail::variant_base_construct_tag{}, + : Base(detail::Variant_base_construct_tag{}, Index, in_place_index, std::forward(value)) @@ -954,12 +954,12 @@ public: } template ::template index_from_type(), + std::size_t Index = detail::Variant_values::template index_from_type(), typename = typename std::enable_if<(Index < sizeof...(Types)) && std::is_constructible::value>::type> constexpr explicit variant(in_place_type_t, Args &&... args) noexcept( std::is_nothrow_constructible::value) - : base(detail::variant_base_construct_tag{}, + : Base(detail::Variant_base_construct_tag{}, Index, in_place_index, std::forward(args)...) @@ -969,7 +969,7 @@ public: typename T, typename U, typename... Args, - std::size_t Index = detail::variant_values::template index_from_type(), + std::size_t Index = detail::Variant_values::template index_from_type(), typename = typename std:: enable_if<(Index < sizeof...(Types)) && std::is_constructible, Args...>::value>::type> @@ -979,7 +979,7 @@ public: Args &&... args) noexcept(std::is_nothrow_constructible, Args...>::value) - : base(detail::variant_base_construct_tag{}, + : Base(detail::Variant_base_construct_tag{}, Index, in_place_index, il, @@ -994,7 +994,7 @@ public: constexpr explicit variant(in_place_index_t, Args &&... args) noexcept( std::is_nothrow_constructible>, Args...>::value) - : base(detail::variant_base_construct_tag{}, + : Base(detail::Variant_base_construct_tag{}, Index, in_place_index, std::forward(args)...) @@ -1013,7 +1013,7 @@ public: noexcept(std::is_nothrow_constructible>, std::initializer_list, Args...>::value) - : base(detail::variant_base_construct_tag{}, + : Base(detail::Variant_base_construct_tag{}, Index, in_place_index, il, @@ -1023,14 +1023,14 @@ public: template < typename T, typename Deduced_Type = typename decltype( - detail::variant_hypothetical_overload_set::fn(std::declval()))::type, + detail::Variant_hypothetical_overload_set::fn(std::declval()))::type, std::size_t Index = - detail::variant_values::template index_from_type(), + detail::Variant_values::template index_from_type(), typename = typename std:: enable_if<(Index < sizeof...(Types)) && !std::is_same::type, variant>::value - && !detail::variant_is_in_place_index::type>::value - && !detail::variant_is_in_place_type::type>::value + && !detail::Variant_is_in_place_index::type>::value + && !detail::Variant_is_in_place_type::type>::value && std::is_constructible>, T>::value && std::is_assignable>, @@ -1041,13 +1041,13 @@ public: { if(index_value.get() == Index) { - detail::variant_get::get(values) = std::forward(new_value); + detail::Variant_get::get(values) = std::forward(new_value); } else { values.destruct(index_value.get()); index_value.set(variant_npos); // in case construction throws - auto &value = detail::variant_get::get(values); + auto &value = detail::Variant_get::get(values); new(const_cast(static_cast(std::addressof(value)))) variant_alternative_t>(std::forward(new_value)); index_value.set(Index); @@ -1056,7 +1056,7 @@ public: } template ::template index_from_type(), + std::size_t Index = detail::Variant_values::template index_from_type(), typename = typename std::enable_if<(Index < sizeof...(Types)) && std::is_constructible::value>::type> void emplace(Args &&... args) @@ -1067,7 +1067,7 @@ public: typename T, typename U, typename... Args, - std::size_t Index = detail::variant_values::template index_from_type(), + std::size_t Index = detail::Variant_values::template index_from_type(), typename = typename std:: enable_if<(Index < sizeof...(Types)) && std::is_constructible, Args...>::value>::type> @@ -1086,7 +1086,7 @@ public: { values.destruct(index_value.get()); index_value.set(variant_npos); // in case construction throws - auto &value = detail::variant_get::get(values); + auto &value = detail::Variant_get::get(values); new(const_cast(static_cast(std::addressof(value)))) variant_alternative_t>(std::forward(args)...); index_value.set(Index); @@ -1104,7 +1104,7 @@ public: { values.destruct(index_value.get()); index_value.set(variant_npos); // in case construction throws - auto &value = detail::variant_get::get(values); + auto &value = detail::Variant_get::get(values); new(const_cast(static_cast(std::addressof(value)))) variant_alternative_t>(il, std::forward(args)...); index_value.set(Index); @@ -1120,8 +1120,8 @@ public: template ::is_swappable>::type> - void swap(variant &rt) noexcept(detail::variant_values::is_nothrow_swappable) + && detail::Variant_values::is_swappable>::type> + void swap(variant &rt) noexcept(detail::Variant_values::is_nothrow_swappable) { if(index_value.get() == rt.index_value.get()) values.swap(rt.values, index_value.get()); @@ -1141,14 +1141,14 @@ public: const variant &v); template friend constexpr - typename std::enable_if::is_equals_comparable, bool>::type + typename std::enable_if::is_equals_comparable, bool>::type operator==(const variant &l, const variant &r) noexcept( - detail::variant_values::is_nothrow_equals_comparable); + detail::Variant_values::is_nothrow_equals_comparable); template friend constexpr - typename std::enable_if::is_less_comparable, bool>::type + typename std::enable_if::is_less_comparable, bool>::type operator<(const variant &l, const variant &r) noexcept( - detail::variant_values::is_nothrow_less_comparable); + detail::Variant_values::is_nothrow_less_comparable); template friend typename std::common_type()(std::declval()))...>::type @@ -1170,7 +1170,7 @@ public: template constexpr bool holds_alternative(const variant &v) noexcept { - constexpr std::size_t index = detail::variant_values::template index_from_type(); + constexpr std::size_t index = detail::Variant_values::template index_from_type(); static_assert(index != variant_npos, ""); return v.index_value.get() == index; } @@ -1180,7 +1180,7 @@ constexpr variant_alternative_t> &get(variant { static_assert(Index < sizeof...(Types), ""); if(v.index_value.get() == Index) - return detail::variant_get::get(v.values); + return detail::Variant_get::get(v.values); throw bad_variant_access(); } @@ -1189,7 +1189,7 @@ constexpr const variant_alternative_t> &get(const varia { static_assert(Index < sizeof...(Types), ""); if(v.index_value.get() == Index) - return detail::variant_get::get(v.values); + return detail::Variant_get::get(v.values); throw bad_variant_access(); } @@ -1208,25 +1208,25 @@ constexpr variant_alternative_t> &&get(variant constexpr const T &get(const variant &v) { - return get::template index_from_type()>(v); + return get::template index_from_type()>(v); } template constexpr T &get(variant &v) { - return get::template index_from_type()>(v); + return get::template index_from_type()>(v); } template constexpr const T &&get(const variant &&v) { - return get::template index_from_type()>(std::move(v)); + return get::template index_from_type()>(std::move(v)); } template constexpr T &&get(variant &&v) { - return get::template index_from_type()>(std::move(v)); + return get::template index_from_type()>(std::move(v)); } template @@ -1251,20 +1251,20 @@ constexpr variant_alternative_t> *get_if(variant constexpr const T *get_if(const variant *v) noexcept { - return get_if::template index_from_type()>(v); + return get_if::template index_from_type()>(v); } template constexpr T *get_if(variant *v) noexcept { - return get_if::template index_from_type()>(v); + return get_if::template index_from_type()>(v); } template constexpr - typename std::enable_if::is_equals_comparable, bool>::type + typename std::enable_if::is_equals_comparable, bool>::type operator==(const variant &l, const variant &r) noexcept( - detail::variant_values::is_nothrow_equals_comparable) + detail::Variant_values::is_nothrow_equals_comparable) { return l.index_value.get() == r.index_value.get() && l.values.is_equal(r.values, l.index_value.get()); @@ -1272,17 +1272,17 @@ constexpr template constexpr - typename std::enable_if::is_equals_comparable, bool>::type + typename std::enable_if::is_equals_comparable, bool>::type operator!=(const variant &l, const variant &r) noexcept( - detail::variant_values::is_nothrow_equals_comparable) + detail::Variant_values::is_nothrow_equals_comparable) { return !operator==(l, r); } template -constexpr typename std::enable_if::is_less_comparable, bool>::type +constexpr typename std::enable_if::is_less_comparable, bool>::type operator<(const variant &l, const variant &r) noexcept( - detail::variant_values::is_nothrow_less_comparable) + detail::Variant_values::is_nothrow_less_comparable) { if(l.index_value.get() != r.index_value.get()) return l.index_value.get() < r.index_value.get(); @@ -1290,25 +1290,25 @@ constexpr typename std::enable_if::is_less_comp } template -constexpr typename std::enable_if::is_less_comparable, bool>::type +constexpr typename std::enable_if::is_less_comparable, bool>::type operator>(const variant &l, const variant &r) noexcept( - detail::variant_values::is_nothrow_less_comparable) + detail::Variant_values::is_nothrow_less_comparable) { return operator<(r, l); } template -constexpr typename std::enable_if::is_less_comparable, bool>::type +constexpr typename std::enable_if::is_less_comparable, bool>::type operator>=(const variant &l, const variant &r) noexcept( - detail::variant_values::is_nothrow_less_comparable) + detail::Variant_values::is_nothrow_less_comparable) { return !operator<(l, r); } template -constexpr typename std::enable_if::is_less_comparable, bool>::type +constexpr typename std::enable_if::is_less_comparable, bool>::type operator<=(const variant &l, const variant &r) noexcept( - detail::variant_values::is_nothrow_less_comparable) + detail::Variant_values::is_nothrow_less_comparable) { return !operator<(r, l); } @@ -1439,10 +1439,10 @@ struct hash> template ::is_swappable>::type> + enable_if::is_swappable>::type> inline void swap(vulkan_cpu::util::variant &l, vulkan_cpu::util::variant &r) noexcept( - vulkan_cpu::util::detail::variant_values::is_nothrow_swappable) + vulkan_cpu::util::detail::Variant_values::is_nothrow_swappable) { l.swap(r); } diff --git a/src/util/void_t.h b/src/util/void_t.h index 7c280f0..5aed59e 100644 --- a/src/util/void_t.h +++ b/src/util/void_t.h @@ -31,14 +31,14 @@ namespace util namespace detail { template -struct void_t_helper +struct Void_t_helper { typedef void type; }; } template -using void_t = typename detail::void_t_helper::type; +using void_t = typename detail::Void_t_helper::type; } }