#pragma once /** * @file * * Template implementations (as opposed to mere declarations). * * One only needs to include this when one is declaring a * `BaseClass` setting, or as derived class of such an * instantiation. */ #include "config.hh" namespace nix { template<> struct BaseSetting::trait { static constexpr bool appendable = true; }; template<> struct BaseSetting::trait { static constexpr bool appendable = true; }; template<> struct BaseSetting::trait { static constexpr bool appendable = true; }; template<> struct BaseSetting>::trait { static constexpr bool appendable = true; }; template struct BaseSetting::trait { static constexpr bool appendable = false; }; template bool BaseSetting::isAppendable() { return trait::appendable; } template<> void BaseSetting::appendOrSet(Strings && newValue, bool append); template<> void BaseSetting::appendOrSet(StringSet && newValue, bool append); template<> void BaseSetting::appendOrSet(StringMap && newValue, bool append); template<> void BaseSetting>::appendOrSet(std::set && newValue, bool append); template void BaseSetting::appendOrSet(T && newValue, bool append) { static_assert(!trait::appendable, "using default `appendOrSet` implementation with an appendable type"); assert(!append); value = std::move(newValue); } template void BaseSetting::set(const std::string & str, bool append) { if (experimentalFeatureSettings.isEnabled(experimentalFeature)) appendOrSet(parse(str), append); else { assert(experimentalFeature); warn("Ignoring setting '%s' because experimental feature '%s' is not enabled", name, showExperimentalFeature(*experimentalFeature)); } } }