module AtCoderFriends::Generator::CxxBuiltinConstGen

generates C++ constants

Public Instance Methods

cnv_const_value(v) click to toggle source
# File lib/at_coder_friends/generator/cxx_builtin.rb, line 16
def cnv_const_value(v)
  v
    .sub(/\b10\^/, '1e')
    .sub(/\b2\^/, '1<<')
    .gsub(',', "'")
end
gen_const(c) click to toggle source
# File lib/at_coder_friends/generator/cxx_builtin.rb, line 7
def gen_const(c)
  v = cnv_const_value(c.value)
  if c.type == :max
    "const int #{c.name.upcase}_MAX = #{v};"
  else
    "const int MOD = #{v};"
  end
end