brew/Library/Homebrew/cxxstdlib.rb

30 lines
597 B
Ruby
Raw Normal View History

2020-10-10 14:16:11 +02:00
# typed: true
# frozen_string_literal: true
require "compilers"
2020-08-14 03:39:31 +02:00
# Combination of C++ standard library and compiler.
class CxxStdlib
def self.create(type, compiler)
2020-12-01 17:04:59 +00:00
raise ArgumentError, "Invalid C++ stdlib type: #{type}" if type && [:libstdcxx, :libcxx].exclude?(type)
2018-09-17 02:45:00 +02:00
CxxStdlib.new(type, compiler)
end
attr_reader :type, :compiler
def initialize(type, compiler)
@type = type
@compiler = compiler.to_sym
end
def type_string
type.to_s.gsub(/cxx$/, "c++")
end
2020-10-20 12:03:48 +02:00
sig { returns(String) }
2014-08-03 15:28:26 -05:00
def inspect
"#<#{self.class.name}: #{compiler} #{type}>"
end
end